I'm trying to have launchd run a shell script when I join a new WiFi network. I've created this plist file (closely based on this SuperUser answer) at
<?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"> <dict> <key>Label</key> <string>my.networkChangeListener</string> <key>LowPriorityIO</key> <true/> <key>ProgramArguments</key> <array> <string>/Users/myname/bin/networkChangeListener/onNetworkChange.sh</string> </array> <key>WatchPaths</key> <array> <string>/etc/resolv.conf</string> <string>/Library/Preferences/SystemConfiguration/NetworkInterfaces.plist</string> <string>/Library/Preferences/SystemConfiguration/com.apple.airport.preferences.plist</string> </array> <key>RunAtLoad</key> <true/> </dict> </plist>
My user is the owner of the plist, and the group is "staff".
When I try to load the file by running
launchctl load ~/Library/LaunchAgents/my.networkChangeListener.plist, I get an error saying "Invalid property list".
However, when I run
plutil ~/Library/LaunchAgents/my.networkChangeListener.plist, it returns "OK"
What is the problem with my plist file? Is is something specific to launchd? I'm completely at a dead end for how to debug this.