Flabby Rabbit | The offical home of The Rabbit

Archive for the "Bash" Category

Setting default monitor for Ubuntu

When using dual screen the gnome panels automatically get attached to the default monitor. If you have something like nvidia x-config you can easily change this using their software, but what if you don’t? Open up a new terminal window and enter: xrandr –prop | grep "[^dis]connected" | cut –delimiter=" " -f1 This will display [...]

Read More ›

Automatic Website Screenshots

I wanted to make an archive of certain sites at a regular interval. But how to get a screenshot of a website automatically? I found this http://www.debian-administration.org/articles/413 which was almost there but not really what I was looking for. I have adapted the script to closer meet my requirements. #!/bin/bash SITE="http://www.hackthis.co.uk" FILE="hackthis-$(date +%F).jpg" vncserver :1 [...]

Read More ›

Connect to SSH with bash script

sudo nano /bin/connect #!/usr/bin/expect -f spawn ssh user@example.com match_max 100000 # Wait for password prompt expect "*password:*" send — "password\r" send — "\r" interact #expect eof Changes need to be made on these lines: spawn ssh user@example.com send — “password\r” Now allow the script to be executed by all users on your system sudo chmod [...]

Read More ›

Checking if a file has been modified using Bash and Crontab – Part 2

After reading the first part you should already know I have a fully working bash script. That will launch a screened PHP script if a file has not been edited for the previous 15 minutes. This part we will be looking at automating the script using crontab. A crontab file contains instructions to the cron [...]

Read More ›

Checking if a file has been modified using Bash and Crontab – Part 1

I needed to check if a file had been edited in the last 15 minutes. This seemed like the simplest way to check if a PHP script was still running. I started off by creating a bash script the, hopefully, would compare the current time and the last modified time stamp on the file. I [...]

Read More ›

 

Essentials