运行 命令行应用程序在后台使用启动代理 mac os x
Running command line app in the background using launchagents mac os x
我有一个命令行应用程序,当用户登录时需要 运行。我已将 XML 文件添加到用户的启动代理目录。应用程序 运行s 但问题是它在 运行s 时打开终端。我希望它在后台 运行 而用户不知道。这是我的 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>LaunchOnlyOnce</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/open</string>
<string>-n</string>
<string>/Applications/Host</string>
</array>
<key>KeepAlive</key>
<false/>
<key>Label</key>
<string>com.test.httphost</string>
<key>RunAtLoad</key>
<true/>
</dict>
我该怎么做?
我预计问题出在调用 open
上。如果您直接调用 /Applications/Host,它应该会按预期工作。
但是,如果您需要 -n
参数来打开,请尝试通过使用 -c
参数调用 /bin/bash
来调用它,并将命令的其余部分传递给 bash 与一个字符串。
我有一个命令行应用程序,当用户登录时需要 运行。我已将 XML 文件添加到用户的启动代理目录。应用程序 运行s 但问题是它在 运行s 时打开终端。我希望它在后台 运行 而用户不知道。这是我的 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>LaunchOnlyOnce</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/open</string>
<string>-n</string>
<string>/Applications/Host</string>
</array>
<key>KeepAlive</key>
<false/>
<key>Label</key>
<string>com.test.httphost</string>
<key>RunAtLoad</key>
<true/>
</dict>
我该怎么做?
我预计问题出在调用 open
上。如果您直接调用 /Applications/Host,它应该会按预期工作。
但是,如果您需要 -n
参数来打开,请尝试通过使用 -c
参数调用 /bin/bash
来调用它,并将命令的其余部分传递给 bash 与一个字符串。