con uno strano problema qui. Ho ~/Library/LaunchAgents/com.me.helloworld.plist con il seguente contenuto:launchd: WatchPath non attiverà il semplice script "ciao mondo" (OS X 10.8)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.me.helloworld</string>
<key>ProgramArguments</key>
<array>
<string>/Users/me/temp/test.sh</string>
</array>
<key>WatchPaths</key>
<array>
<string>/Users/me/temp/Journal.txt</string>
</array>
</dict>
</plist>
L'idea è, se ~/temp/Journal.txt viene modificata, deve essere avviata a ~/temp/test .sh. test.sh ha il seguente contenuto:
#!/bin/bash
echo "hello world from test.sh" >> itchanged.txt
Quindi, se cambio Journal.txt, dovrei ottenere un file chiamato itchanged.txt. Quando faccio quanto segue:
$ launchctl unload ~/Library/LaunchAgents/com.me.helloworld.plist
$ launchctl load ~/Library/LaunchAgents/com.me.helloworld.plist
$ touch Journal.txt
Fare un ls mostra che test.txt non è stato creato. Tuttavia, se eseguo manualmente un file ./test.sh, viene creato itchanged.txt. Quindi il problema sembra essere da qualche parte nel riconoscere che Journal.txt è cambiato ed eseguire lo script quando questo accade.
Sto usando OS X Mountain Lion. Qualche idea?
Questo ha funzionato! Grazie mille, Gordon. – user1940620