How do I run a script after connecting to a network?

Joined
Jul 29, 2009
Messages
1
Reaction score
0
Points
1
I want to know how I would run a shell script after I connect to a network. For example, when my MBP wakes when I open it and it connects to my home wireless, I would like to run a script after it connects.

I would like to know how to do this in general for any script. However, my reason for wanting to do this now is because I am using hamachi as a vpn between computers and I have found that when my network reconnects after the os wakes, hamachi needs to be stopped and restarted in order to work properly.

Any info would help.

Thanks.
 
Joined
Jun 2, 2009
Messages
44
Reaction score
0
Points
6
Location
Chennai
Your Mac's Specs
MacBook Pro 15.4" 2.4GHz C2D 2GB RAM 250GB HDD Mac OS X-10.5.8, Apple iPod nano 8GB Black
I assume, you are a terminal user.

add your script in your .bashrc and make it check whether your interface is up or down.

For eg,

ifconfig en0 | grep active (assuming you are in en0)

This is will report, whether the interface is up or not. You can add a conditional loop in addition, to your script in the .bashrc.

Post back your experiences or comments.
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top