Category Archives: linux

linux and unix related stuffs

Quick and Dirty Speedtouch reboot

I hate my Speedtouch ADSL router. Occasionally it`ll crumple under the weight of some large file transfers and drop the connection to the Internet. It`s a pain in the arse. However, it`s currently not the right time to buy a replacement. I therefore set up a quick cron job to ping a few Internet sites, and if these fail, kick off a script to reboot the router.

The ping part is pretty simple, so go off and research that. For the reboot, it`s some crappy python and “pexpect”, like so:

#!/usr/bin/python
#
# apt-get install python-pexpect telnet
# if necessary – or through the package manager of your
# choosing
#

import pexpect
import sys

child = pexpect.spawn(‘telnet 192.168.1.254′)

child.expect(‘sername : ‘, timeout=5)
child.send(‘Administrator\r\n’)

child.expect(‘assword : ‘, timeout=5)
child.send(‘adminpasswordhere\r\n’)

child.expect(‘{Administrator}=>’, timeout=5)
child.send (‘system reboot\r\n’)

Where I tripped up was using “sendline” instead of “send” above – watch out for that as you`ll notice \r\n needs to be sent for a newline. pexpect isn`t very elegant, but it makes this sort of scripting very easy.

Have fun. Also, “assword”. Teehee.

Adventures with Virtual Box

This item was rewritten, August 2011 with the old stuff merged in.

Running VirtualBox from a raw disk.

The previous item.. post.. whatever, was a quick and dirty on using VirtualBox to run a Linux partition inside Windows. This is becoming more and more useful for me as I spend most of my time in Linux Land, but sometimes need to run Windows – then do something quickly on the Linux side. Rebooting becomes more and more of a pain in the arse.

Continue reading