Script to Connect to UW-Wireless Automatically Using Lynx

The uw-wireless authentication web page that shows up when connected to a UW network started to get on my nerves, so I wrote a little script using the lynx text browser to automatically authenticate when connecting to the network. It also performs a simple check to see if the first two numbers of your IP belong to UW.

#!/bin/sh
IP=$(ifconfig eth0 | grep 'inet addr' | awk '{print $2;}' | cut -d: -f 2)
TOP2=$(echo $IP | cut -d. -f 1-2)
if [[ $TOP2 = '129.97' ]]; then
    echo 'Connected to UW Network...'
    lynx -dump -accept_all_cookies -post_data https://uw-wireless.uwaterloo.ca/login/index.php < ~/.uwwireless | grep 'Successfully Connected' | awk '{print $5;}'
else
    echo 'Not connected to UW Network...'
fi

Create the file ~/.uwwireless and place the following in the file, replacing the YOUR_USERID and YOUR_PASSWORD with your own:

userid=YOUR_USERID&password=YOUR_PASSWORD&mode=Connect

Depending on your version of Lynx, the script may fail if the SSL certificate from uw-wireless.uwaterloo.ca is not recognized. I don’t know of a better solution than simply removing the check. Make the following change in /etc/lynx.cfg (or wherever your lynx.cfg may reside) to remove the SSL certificate prompt:

FORCE_SSL_PROMPT:=yes

3 Responses to “Script to Connect to UW-Wireless Automatically Using Lynx”


Leave a Reply