This tutorial should help you reboot your modem/router automatically . You can use this for many reasons . One of the reasons being BSNL provides free night usage between 2 and 8am . Therefore rebooting your modem once at 2am and then at 8am and scheduling your downloads can help you take advantage of free night unlimited. I've already made a similar tutorial for windows . CLICK HERE to view that tutorial . If your using linux (ubuntu ) then this tutorial is for you . SO here's how we do it :

INSTALL EXPECT - tool required for rebooting.

Step 1 : Go to the Terminal ( Applications->Accessories->Terminal) and type sudo apt-get install expect

SETUP REBOOT SCRIPT

Step 1 : Open Text Editor ( Applications->Accessories->Text Editor)
Step 2 : Now Copy - Paste the following code in the text editor and save it as router.exp . Save this file in your home folder . So your overall file link should be something like /home/prash/router.exp .where /home/prash is the link to your home folder

#!/usr/bin/expect -f



# router user name
set name "admin"

# router password
set pass "admin"

# router IP address
set routerip "192.168.1.1"

# Read command as arg to this script
set routercmd [lindex $argv 0]

# start telnet
spawn telnet $routerip

# send username & password
expect "Login:"
send -- "$name\n"
expect "Password:"
send -- "$pass\n"

# get out of ISP's Stupid menu program, go to shell
expect " -> "
send -- "reboot\n"

# execute command
expect "# "
send -- "$routercmdr"
# exit
send -- "^D"


Step 3 : Now Go to the Terminal (Applications->Accessories->Terminal) and type crontab -e
Step 4 : Then add the following 2 lines

15 2 * * * /home/prash/router.exp
45 7 * * * /home/prash/router.exp


NOTE : Replace /home/prash with your home directory link. The above 2 lines reboots your router at 2:15am and 7:45am respectively

Step 5 : Then Press CTRL+X to SAVE and then Press Y ( to confirm)

Step 6 : Thats it , your done , your modem/router should reboot

NOTE : This script works for ut300r2u . The script may need to be modified a bit for other modems.You could check THIS tutorial for scripts in windows and modify it to work in ubuntu. Just a little modification is required.For Huawei modems , your script would be :

#!/usr/bin/expect -f



# router user name
set name "admin"

# router password
set pass "admin"

# router IP address
set routerip "192.168.1.1"

# Read command as arg to this script
set routercmd [lindex $argv 0]

# start telnet
spawn telnet $routerip

# send username & password
expect "Login:"
send -- "$name\n"
expect "Password:"
send -- "$pass\n"

# get out of ISP's Stupid menu program, go to shell
expect " -> "
send -- "system restart\n"

# execute command
expect "# "
send -- "$routercmdr"
# exit
send -- "^D"


7 comments

Dinesh said... @ December 5, 2009 at 5:51 AM

hi , i am using ubuntu 9.04 i used both the script spedified by you with gnome-schduler ,my router is WA3002G4 but it is not working . Could you please help me out?

Prash Babu said... @ December 5, 2009 at 6:54 AM

have you used any reboot script on windows before? or your trying this out for the first time?

Unknown said... @ May 24, 2010 at 3:27 PM

Dont know if its a stupid question...But how will I know if my modem has been rebooted or not??

Prash Babu said... @ May 27, 2010 at 9:24 PM

if you look at the lights on the router , you will notice that the power LED would blink..

Sanjay Vinayak said... @ May 5, 2011 at 3:13 AM

plz send reboot script for WA3002G4
in windows the reboot script is same as that of SIEMENS sl2_141

Sanjay Vinayak said... @ May 5, 2011 at 3:44 AM

srry prash i worked out the reboot script for WA3002G4 myself. This is it:
#!/usr/bin/env expect

set username admin
set pass admin
set host 192.168.1.1

spawn telnet ${host}

expect -re "Login:"
send "${username}\r"

expect "Password:"
send "${pass}\r"

expect -re "->"
send "13\r"
send "1\r"
expect eof

Jaikumar said... @ November 30, 2012 at 5:10 PM

Hi,

Expect is available in \usr\bin\, but still I am getting this following error:

router.exp: 18: router.exp: spawn: not found
couldn't read file "Login:": no such file or directory
router.exp: 22: router.exp: send: not found
couldn't read file "Password:": no such file or directory
router.exp: 24: router.exp: send: not found
couldn't read file " -> ": no such file or directory
router.exp: 28: router.exp: send: not found
couldn't read file "# ": no such file or directory
router.exp: 32: router.exp: send: not found
router.exp: 34: router.exp: send: not found

Post a Comment