Just found this and it works.(Tried it)
source: *vinuthomas.com/Forums/viewtopic/t=6369.html
Here is a method you can use to make 100 % sure that you don't get over billed for night time usage plan like HOME500.
This procedure assumes that your router/modem is connected to one Ethernet card in your machine.
This was tested on SmartAX MT882 Router, Windows XP, and Ubuntu Edgy.
For Linux (Ubuntu Edgy Eft)
1 RECOMMENDED:- configure your modem to autodial
2 install expect
3 install kalarm in gnome or KDE if it is not already installed, and make sure it run at startup or add the daemon to sessions
4 RECOMMENDED:- Disable internet time server updates (NTP)
sudo update-rc.d ntp-server remove
5 create a file
router.exp with the following contents
Code:
#!/usr/bin/expect -f
set timeout 20
set echo off
# router user name
set name admin
# router password
set pass admin
# your router IP address
set routerip 192.168.1.1
# Read command as arguments to this script
set switch [ lrange $argv 0 1]
if {$switch == "" } {send_user "usage:\n\trouter ON\n\trouter OFF\n\trouter validcommand\n\n"
exit
} else {
if {$switch == "ON"} {set routercmd "pppoe set transport 1 autoconnect enabled\r"
} else {
if {$switch == "on"} {set routercmd "pppoe set transport 1 autoconnect enabled\r"
} else {
if {$switch == "OFF"} {set routercmd "pppoe set transport 1 disabled\r"
} else {
if {$switch == "off"} {set routercmd "pppoe set transport 1 disabled\r"
} else {
set switch [ lrange $argv 0 9]
set routercmd "$switch\r"
}}}}
}
send_user "sending router:- $switch \n"
#other useful commands
# set routercmd "pppoe list transports\r"
# set routercmd "pppoe show transport 1\r"
# set routercmd "pppoe list transports\r"
# start telnet
spawn telnet $routerip
# send username & password
expect "Login: "
send "$name\r"
expect "Password: "
send "$pass\r"
expect -i "--> "
send $routercmd
send '^]'
expect "telnet> "
send "close\r"
send_user "\nDone!\n"
exit
6. Enter your router IP, router username, router password in the script
NOTE
if you have some other router change the script to respond according to the menu that you get while you telnet your router)
7. Schedule the following commands in kalarm to run in terminal
Code: /your_script_location/./router.exp OFF 1:50am and 7:50am ( or fancy your time ! )
Code: /your_script_location/./router.exp ON 2:10am ( or fancy your time ! )
! be careful with the schedules and make sure that you test it
For Windows XP
This method is safer than using a dialer like the one in DAP because in XP there is a good probability that things can crash.
1) RECOMMENDED:- configure your modem to autodial
2) download TS10 from www.winsite.com/bin/In...0000000873
3) create two text files
enable.txt
Code: 192.168.1.1
WAIT "Login: "
SEND "admin\m"
WAIT "Password: "
SEND "admin\m"
WAIT "--> "
SEND "pppoe set transport 1 autoconnect enabled\m"
disable.txt
Code: 192.168.1.1
WAIT "Login: "
SEND "admin\m"
WAIT "Password: "
SEND "admin\m"
WAIT "--> "
SEND "pppoe set transport 1 disabled\m"
4) create two .bat files (open notepad and save as "routerON.bat" and "routerOFF.bat")
with the following contents
routerON.bat
Code: chdir C:\RouterSwitch
c:
TST10 /r:enable.txt /o:last_log.txt
routerOFF.bat
Code: chdir C:\RouterSwitch
c:
TST10 /r:disable.txt /o:last_log.txt
5) Create an empty file called last_log.txt to diagnose output of the last run script.Save all the files TST10.exe,enable.txt,disable.txt,routerON.bat,routerOFF.bat
in C:\RouterSwitch
6) schedule the routerOFF.bat to run 1:50am and 7:50am (! or fancy your time )
schedule the routerON.bat to run 2:10am (! or fancy ur time )
7) RECOMMENDED :- to shutdown your computer you don't need to trust a third party app , forced shutdown is probably more successful in different conditions
to do that create a file
shut.bat with the following line
Code: shutdown -f -s -t 30 and schedule to run at
your time
this will display a 30 sec warning to all users logged in to your computer
(make sure that u run the scripts once, and test it and make sure your firewall and/or anti virus remembers the settings)
For dynamic IP users (eg-HOME500)
whenever you wanna change your external IP,
(that is disconnect and reconnect)
when autodial is enabled in router you dont need to reach for router switch.
Just run this at terminal or command prompt
Quote: in linux
./router.exp OFF
./router.exp ON
in windows
routerOFF
routerON
*vinuthomas.com/images/smiles/icon_exclaim.gif
[NOTE:- in case of power failure or modem restart, you will still be in automatically connected after disconnected by routerOFF.bat in windows
or ./router.exp OFF in linux]
*vinuthomas.com/images/smiles/icon_biggrin.gif
A worst case scenario:
just a good UPS will save you
router OFF at 7:55am (BSNL TIME *vinuthomas.com/images/smiles/icon_twisted.gif )
PC shutdown at 7:56am (BSNL TIME )
power fluctuation or modem restart at 7:57am (BSNL TIME ) *vinuthomas.com/images/smiles/icon_question.gif
modem has LAN link even after PC shutdown *vinuthomas.com/images/smiles/icon_question.gif
your router gets auto connected *vinuthomas.com/images/smiles/icon_exclaim.gif
You will be charged for *vinuthomas.com/images/smiles/icon_question.gif
*vinuthomas.com/images/icons/icon_disk.gif(*vinuthomas.com/Forums/download/id=184.html) Description:
Linux (expect script)
Filename: router.zip Filesize: 576 Bytes Downloaded: 48 Time(s)
*vinuthomas.com/images/icons/icon_disk.gif*vinuthomas.com/Forums/download/id=183.html Description:
For Windows XP
Filename: routerswitch.zip Filesize: 191.21 KB Downloaded: 97 Time(s)
Use Auto Power on to run the .bat files at the sceduled time.
Difference between BSNL time and windows time : approx. +5min i.e. BSNL is 5 minutes behind windows time. So connect the router at 2.07 am and disconnect at 8.03 am.
Use server : "chime.utoronto.ca" for getting the time.
Here's my download chart:
Start
Time Stop
Time Send
(KB) Receive
(KB) Combined
(KB) Duration
(seconds) Daily Total 2007/06/03 02:00:07 07:59:41 1046541 2407213 3453754 21574
2007/06/03
3453754 KB
3372.81 MB
5 hr 00 m