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.

What would be a good way to make a script run every time my computer connects to the network in Ubuntu? Would I somehow use dbus to do this?

Background: when I'm on the train I run a short Perl script to click a button on the splash page. That way I can immediately use the internet without having to manually visit a pointless website. My script is a near-perfect solution, but it would be perfect if it could run automatically any time I connect to the network.

share|improve this question
    
not important to the question, but here is the one-liner: alias dodgesplash='perl -e '\''use WWW::Mechanize; $mech = WWW::Mechanize->new(); $mech->get("is.gd"); $mech->click();'\''' –  rplevy Feb 27 '10 at 1:07

2 Answers 2

up vote 2 down vote accepted

Put a script in /etc/network/if-up.d and make it executable.

share|improve this answer

You can put a script in /etc/NetworkManager/dispatcher.d which will be run whenever a connection goes up or down. See the man page for NetworkManager for the details.

share|improve this answer

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.