views:

87

answers:

2

In my university there's a certain wlan network open for the students and employees. To use it, however, one must first log in via a website using your own username and password. This can also be done by submitting a http request with the right POST-data to the same website. I already have a shell script that does this but I'm still curious to whether it would be possible to have this script run automagically every time my computer connects to the university wlan. Is it possible to do this in some semi-easy way?

A: 

You might write a simple script that runs "iwconfig" and processes it's output. If the name of the network is found (with Regex for example) you send a request.

I don't think you can trigger the script when you are acutally connected to the network, but you can add it to CRON, so it is executed for example every ten seconds.

Heres's a document you may find helpful: https://help.ubuntu.com/community/CronHowto

Jacek
+2  A: 

I know that NetworkManager (which is used in Ubuntu) exposes a DBUS interface -- I would suspect there is an event for network connected / disconnected which you could use. Try checking the NetworkManager DBUS Interface spec.

If you've never worked with DBUS before, fear not, there are bindings for pretty much every language. I'm sure there's even a CLI client you could invoke from a shell script. This blog entry shows how to detect a new connection from NetworkManager with Python -- it might be a good starting point

John Ledbetter
This looks like fun! I think I'll give it a shot.
nici