Asianet dataline internet autoconnect script

In my hostel, we use asianet dataline internet connection. The connection is established through a webpage authentication and it needs to keep that webpage always open in the browser to get the stable connection. Once we login and releave that page, after five minutes it will require a re-login. Its a real hurdle to keep a page open in the browser for internet authentication.

I just analyzed the http requests from that page and automated using the curl utility.

Here is the script it feel, it would be useful for many.

#!/bin/bash

customer=CNXXXX password=XXXXXX

if [ -n “ifconfig | grep -A 1 wlan0 | grep "inet addr"” ]; then

curl https://mwcp-ekm-04.adlkerala.com:8001 –data “auth_user=$customer&auth_pass=$password&accept=Login” &> /dev/null

echo “Connected :)”

while true do sleep 300 curl https://mwcp-ekm-04.adlkerala.com:8001 –data “alive=y&un=$customer” &> /dev/null ;

done

else

echo “Wifi not connected”;

fi

</code>

Copy down the above script in a text file and rename to internet.sh

slynux@slynux-laptop:~$ chmod a+x internet.sh slynux@slynux-laptop:~$ ./internet.sh Connected :) </code>

This script has an initial check for ethernet interface. Here it is given Wifi interface, wlan0. If you use a LAN for connection change wlan0 to eth0 and the message as well :)