Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to have a script run when I connect to a wireless network?

My university hijacks all HTTP(S) connections when you first connect to force you to log in with your university account. I've already written a script to take care of the log in, but I would like to have it run automatically when I connect to the network.

share|improve this question
up vote 1 down vote accepted

I'm pretty sure the Wicd network manager can do that. You might want to check it out, I know it work on ubuntu and opesuse

share|improve this answer

Network Manager will automatically run scripts in certain directories at certain stages of network connection.

Loo in /etc/network. You'll see four directories, with self-explanatory names (given that "if" stands for "network interface"). You're looking for if-up.d. Put your script in there, name it something like 50-university-login.sh, and mark it executable.

In case you're wondering, the numbered prefixes give the scripts an order. the "default" is 50, halfway from 01 to 99.

share|improve this answer
    
Old answer, but this doesn't work for me (anymore). I'm trying to run a script when (wlan0) connects to a hotspot. The script parses iwconfig and works when I manually call it. I'm on Lucid and I symlinked my script into /etc/network/if-up.d/ and it's never executed. Any idea why? – Till Aug 26 '10 at 15:31
    
Check this link: wiki.ubuntu.com/OnNetworkConnectionRunScript I had to do the second part, I guess I'm not using Network Manager – Sloy Jul 22 '13 at 12:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .