# Auto Login WiFi – University, Hotels Etc

When using the University WiFi I found it annoying that I always had to login through a browser using my university username and password. Using the simple scripts below, this bothersome procedure can be done automatically each time the computer discovers a network. I am using Wicd Network Manager, which has a nice feature where one can include scripts that you want to run when the computer connects and disconnects to a network ( see wicd documentation). Using this feature I made a short script to run different tasks when the computer discovered different Wifi’s. I have a file called perform_on_post_connect.sh in the directory /etc/wicd/scripts/postconnect on my linux machine with the following code:

#!/bin/bash

essid=$2 connection_type=$1

if 	[ "${essid}" == "Foo network" ]; then # do something when logging into 'Foo network' ./myscripts/foo_autologin.py elif [ "${essid}" == "Bar network" ]; then
# do something else when connecting to 'Bar network'
fi


I then use a python script called foo_autologin.py that performs the nessecary login procedure. If I am not mistaken, with Wicd one has to have this in a directory with only root access. The source for foo_autologin.py:

#!/usr/bin/python
import requests
import sys

#
# AUTO LOGIN TO Foo NETWORK
#

print "This is an automatic login to Foo network"

def main():
# Start a session so we can have persistant cookies
session = requests.session(config={'verbose': sys.stderr})
# use headers that is posted in the HTML POSt method
'buttonClicked':'4',
'err_flag':'0',
}