Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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

I have two one-liner scripts that write IP address and SSID to files in my Dropbox; I would like my Android phone to sync to Dropbox and read the IP and SSID and do stuff via Tasker if it's on the same network.

That said, I am looking for a way to execute the scripts whenever I'm connected to wifi.

Thanks very much for the help!

share|improve this question
possible duplicate of Execute a script after a VPN connection is started – enzotib Sep 18 '11 at 7:26
@enzotib - it's not exactly a duplicate, but that answer helped me out a lot. I'm still looking for a way to run a script pre-disconnect as well - basically I'm writing files to Dropbox based on the current network status of my laptop; before wireless shuts off I want to write to Dropbox and give it enough time to sync the changes to the cloud. – Dang Khoa Sep 18 '11 at 21:46
up vote 2 down vote accepted

I had to add the following to my /etc/network/interfaces:

auto wlan0
iface wlan0 inet dhcp

Then place a script in /etc/network/if-up.d/ and check if "$IFACE" = "wlan0".

share|improve this answer

Your Answer


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.