6
這裏有一個奇怪的問題。我有〜/庫/ LaunchAgents/com.me.helloworld.plist具有以下內容:launchd:WatchPaths不會觸發簡單的「hello world」腳本(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>
的想法是,如果〜/溫度/ Journal.txt被修改,它應該執行〜/溫度/測試.SH。 test.sh有以下內容:
#!/bin/bash
echo "hello world from test.sh" >> itchanged.txt
所以,如果我改變Journal.txt,我應該得到一個名爲itchanged.txt文件。當我做到以下幾點:
$ launchctl unload ~/Library/LaunchAgents/com.me.helloworld.plist
$ launchctl load ~/Library/LaunchAgents/com.me.helloworld.plist
$ touch Journal.txt
做一個LS表明test.txt的不創建。但是,如果我手動執行./test.sh,則會創建它changed.txt。所以這個問題似乎是在認識到Journal.txt被更改並在發生這種情況時執行腳本的地方。
我使用的是OS X Mountain Lion。有任何想法嗎?
這工作!非常感謝,戈登。 – user1940620