Created
November 14, 2010 04:41
-
-
Save prehensile/675916 to your computer and use it in GitHub Desktop.
A launchd daemon to execute a Python script when network configuration changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" | |
"http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>Label</key> | |
<string>prehensile.networkwatcher</string> | |
<key>ProgramArguments</key> | |
<array> | |
<string>/usr/bin/python</string> | |
<string>/Users/henry/Scripts/BigPicture.py</string> | |
</array> | |
<key>WatchPaths</key> | |
<array> | |
<string>/Library/Preferences/SystemConfiguration</string> | |
</array> | |
</dict> | |
</plist> |
Hey @GabLeRoux I'm trying to get something like this to work -- I've adjusted the plist file a bit with my own paths, put it in the LaunchDaemons folder, changed the rights, and launched it.
I figure it should run if I turn off and on Wifi, (I think?), but it doesn't .
When I run launchctl list I see the file listed, but it doesn't have a PID, so does that mean it's not running properly?
Any thoughts on how I can get this to work?
// Figured this out - had a line in my .py script that was causing an error because I assumed the location of a reference file was relative to the .py location, but instead the script was running from the /Library/LaunchDaemons folder.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Write this to
/Library/LaunchDaemons/prehensile.networkwatcher.plist
.Make sure it has the correct rights:
Launch the daemon
Notes
network.watcher.plist
python
like in the above ;)