Tuesday, November 17, 2009

BSNL Broadband free night surfing UTStarcom 3002G4

Many plans in BSNL Broadband ofer free surfing during 02:00 to 08:00 Hours. The twist is that the user must re-login after 02:00 Hours. Any usage starting before the free period but continuing into it will be charged at the usual rate. If are using a UTStarcom 3002G4 router in the bridged (always on) mode all you need to attain is a re-boot of the router after 02:00 AM.

Scheduling text based downloads to take advantage of the free period without having to wait till 2:00 AM to switch-off and switch-on the router can be avoided using a few shell scripts. While attempting the these instructions please make sure that your system time is set to IST correctly. To make matters a bit safer, I have scripted in such a way that the router re-boots at 02:10 AM to accomodate for upto 10 minute discrepancy between the system clock and IST.

It is quite simple to set a cron job at 02:10 AM to re-boot the modem and to run the scripts for starting the download. But I found that cron jobs run in the background so when we need to stop the downloads and to re-boot the router as 08:00 AM approaches, we have to wade through a whole host of processes using "ps -ef" and ensure that we individually "kill -9" all relevant processes set off by our script.

Therefore I devised a couple of scripts. All we have to do is execute the first script (dlstart.sh), at our convenience, anytime on the previous day from a terminal. After that we can switch-off the monitor and save some power too.

The procedure first calculates the number of seconds until the next 02:10 AM and issues a "sleep" for this period. Subsequent to sleeping, the script can invoke any download command of our choice like "wget","downloadcurses" or any other.

Before 08:00 AM, switch on the monitor and close the ongoing download process and re-boot the router by typing without quotes "router-reboot.sh | telnet" or by simply toggling it off and on.

Main Script "dlstart.sh" to be placed in /usr/bin with mode 777

==========
#!/bin/bash

# Automatic Download from 02:00 HRS

cd /home/ebby/Downloads/rsdown_linux

# Calculating seconds till next 02:10 HRS

da="$(date +%Y)-$(date +%m)-$(date +%d)"
day1=$(date -d "$da +1 day" +%s)
day2=$(date +%s)
slp=`expr $day1 - $day2 + 7800`

echo sleeping for $slp seconds !

sleep $slp

sh router-reboot.sh | telnet

sh "your favourite dowload command with path"
============

Script "router-reboot.sh" to be placed at /usr/bin with 777 mode

=============
#!/bin/bash

# script to be used with telnet to reboot UTStarcom 3003G4 router usually supplied by BSNL

# Put this file in /usr/bin directory with 777 mode
# Type without quotes "router-reboot.sh | telnet" to reboot the router

echo 'o 192.168.1.1 23'

sleep 2
echo 'admin'

sleep 2
echo 'admin'

sleep 2

echo 'reboot'

sleep 60
===========



Disclaimer:

The author has tested this procedure successfully only a UTRStarcom 3002G4 router. Anyone trying it out shall doing so at his/her own risk. The author shall not be resposible for any damage or loss that may occur on account of running these scripts.

This works only for bridged (always on) routers

No comments:

Post a Comment