Anand Srinivasan
Anand Srinivasan

Reputation: 470

Running command line app in the background using launchagents mac os x

I have a command line application which needs to run when the user logs in. I have added a XML file to the user's launch agent directory. The application runs but the problem is it opens the terminal when it runs. I want it to just run in the background without the user knowing it. This is my 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>

How can I do this?

Upvotes: 0

Views: 2034

Answers (1)

TheDarkKnight
TheDarkKnight

Reputation: 27611

I expect the problem is calling open. If you call /Applications/Host directly, it should work as expected.

However, if you need the -n param for open, try calling it via a call to /bin/bash with the -c parameter and pass in the rest of the command to bash with a string.

Upvotes: 1

Related Questions