我正在尝试使启动脚本的一部分自动化,该脚本将打开一个终端窗口,该窗口将运行命令并在登录时向用户显示一堆文本。
我试图在/ Library / LaunchAgent中创建一个似乎无法解决问题的plist
/LaunchAgents/blah.blah.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "..........">
<plist version="1.0">
<dict>
<key>Label</key>
<string>terminal.menu</string>
<key>RunAtLoad</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>/bin/bash</script>
<string>/Library/Scripts/Startup.sh</string>
</array>
</dict>
</plist>
和Startup.sh看起来像这样
osascript -e 'tell app "Terminal"
do script "echo blah blah ; ssh blah blah"
end tell'
答案 0 :(得分:1)
根据来自here的信息,您可以对.plist
进行一些修改:
label
的值应与您的.plist
的名称(在这种情况下为"blah.blah"
)匹配,或者您应将.plist
保存为"terminal.menu.plist"
您指定了ProgramArguments
,但没有指定Program
。也许如果您更改此设置:
<key>ProgramArguments</key>
<array>
<string>/bin/bash</script>
<string>/Library/Scripts/Startup.sh</string>
</array>
对此:
<key>Program</key>
<string>/Library/Scripts/Startup.sh</string>
所以您的blah.blah.plist
定义现在看起来像这样:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "..........">
<plist version="1.0">
<dict>
<key>Label</key>
<string>blah.blah</string>
<key>Program</key>
<string>/Library/Scripts/Startup.sh</string>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>