Hell Oh Entropy!

Life, Code and everything in between

Checking Reliance Netconnect prepaid account usage

So I've been using the Reliance Netconnect usb dongle since I shifted to Magarpatta City. Since work is so close to home now, I really only need internet access at home to check emails when I wake up (yes, I am an addict). Being a prepaid account, I wanted to know how I could monitor my usage. I asked the vendor and he told me to go to the Usage menu. I told him I use Linux. He insisted that I ought to be going to the usage menu.

I gave up asking him.

And it was a good thing I did, because the information was quite easily available online. All you had to do was go to this URL and enter your MDN, i.e. the number of your netconnect dongle. But that was very cumbersome, so I hacked up this little script so that usage monitoring is now just a command away:

#!/bin/sh

cleanup_temp () {
    rm -f $tempfile
    exit 2
}

if [ $# -lt 1 ]; then
    echo "Usage: $0 <reliance netconnect number>"
    exit 1
fi

trap cleanup_temp SIGINT
trap cleanup_temp SIGTERM
trap cleanup_temp SIGHUP

tempfile=`mktemp`

nc reliancenetconnect.co.in 80 > $tempfile <<ECHO
POST /RNetconnect/RNC/Netconnect_Authentication.jsp HTTP/1.1
Host:reliancenetconnect.co.in
Content-type: application/x-www-form-urlencoded
Content-Length: 14

MDN=$1
ECHO

grep "and your Netconnect" $tempfile | links -dump

rm -f $tempfile

And if you want to make things even simpler, modify the above to read the number from an environment variable and export that variable in your .bashrc.

comments powered by Disqus