【发布时间】:2019-01-31 19:28:35
【问题描述】:
我正在尝试使用 launchd 代理定期运行一个非常简单的 AppleScript,但除了将 AppleScript 内容写入 stdout 之外,它不会做任何事情。
我的launchd代理~/Library/LaunchAgents/com.nn.test.plist:
<?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.nn.test</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/osascript</string>
<string>-e</string>
<string>"display dialog \"Hi\""</string>
</array>
<key>RunAtLoad</key>
<false/>
<key>Debug</key>
<true/>
<key>StartInterval</key>
<integer>7200</integer>
<key>StandardErrorPath</key>
<string>/tmp/test</string>
<key>StandardOutPath</key>
<string>/tmp/testout</string>
</dict>
</plist>
我正在运行:
$ launchctl unload com.nn.test.plist
$ launchctl load com.nn.test.plist
$ launchctl run com.nn.test
结果是cat /tmp/testout
display dialog "Hi"
而/tmp/test 为空。
预期行为会打开一个对话框,就像我直接在 shell 中运行命令时一样(有效),但似乎什么也没发生。 我做错了什么?为什么我在任何错误日志中都看不到任何错误消息?
这可能与 Mojave 的增强安全模型有关吗?不能再从launchd 代理运行 AppleScript 了吗?
【问题讨论】:
标签: macos applescript launchd macos-mojave