I am starting to work with launchd and I want to configure the plist file in such a way that whenever I insert an SD card into my Mac mini-server (with Snow Leopard Server), I want to run a shell script (which should copy all jpg files, rename them, etc.).
So, I created a plist file in ~ / Library / LaunchAgents (see its contents below - it should look for changes in / Volumes), and I created a shell script that says "beep" - this will do something more useful later.
The plist file is logged in using launchctctl, and when I run it (startctl start com.peters.runwhenSDmount), the computer beeps whenever the memory card is connected to the network and remains silent when there is no memory card. Thus, apparantly plist calls the shell script, which subsequently checks for a specific SD card. I guess this also proves that there are no permissions issues for the SD card.
But it doesn't seem to work on its own ??? Any idea why?
plist file: ~ / Library / LaunchAgents / com.peters.runwhenSDmount.plist
<?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>com.peters.runwhenSDmount</string>
<key>LowPriorityIO</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>/Users/peter/Library/Scripts/runwhenSDmount</string>
</array>
<key>ThrottleInterval</key>
<integer>10</integer>
<key>WatchPaths</key>
<array>
<string>/Volumes</string>
</array>
</dict>
</plist>
shell script: ~ / Library / Scripts / runwhenSDmount
#!/bin/bash
if [ -d "/Volumes/NIKON D40X" ]; then
say beep
fi
source
share