Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

2 Answers

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
add comment

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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.