Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

my .plist looks like below ... In /var/log.system.log I can see

(com.example.exampled[24728]): posix_spawn("/usr/local/bin/ruby /Users/radek/Sites/sinatrasvn/web.rb", ...): No such file or directory
(com.example.exampled[24728]): Exited with exit code: 1
(com.example.exampled): Throttling respawn: Will start in 10 seconds

but if I run /usr/local/bin/ruby /Users/radek/Sites/sinatrasvn/web.rb the script works fine. Any idea?

       <?xml version="1.0" encoding="UTF-8"?>
       <!DOCTYPE plist PUBLIC -//Apple Computer//DTD PLIST 1.0//EN       http://www.apple.com/DTDs/PropertyList-1.0.dtd >
       <plist version="1.0">
       <dict>
            <key>Label</key>
    <string>com.example.exampled</string>
    <key>ProgramArguments</key>
    <array>
                 <string>/usr/local/bin/ruby /Users/radek/Sites/sinatrasvn/web.rb</string>
    </array>
    <key>KeepAlive</key>
    <true/>
       </dict>
       </plist>
share|improve this question
up vote 10 down vote accepted

launchd doesn't use the shell to run programs; it uses the exec system call. This is why the plist you have above uses an array.

You are setting a single element of that array to a string containing a space, which leads launchd to attempt to exec("/usr/local/bin/ruby /Users/radek/Sites/sinatrasvn/web.rb") — which, sure enough, is not the name of a file. Instead, you want to set the array:

    <array>
                 <string>/usr/local/bin/ruby</string>
                 <string>/Users/radek/Sites/sinatrasvn/web.rb</string>
    </array>

This will pass the paths as individual arguments to exec(), and the right thing will happen.

share|improve this answer
    
wow.Nicely put.Thank you. Do I have to call launchctl load /Users/radek/Library/LaunchAgents/sinatra.plist after reboot or it is good enouth to call it once? – Radek Mar 4 '11 at 1:42
2  
Everything in ~/Library/LaunchAgents will be automatically loaded every time you log in, so launchctl load ... is only needed for the current login session (or you could just log out & back in). BTW, for locally-developed launchd items like this, you should probably use "local." instead of "com.example." as a label prefix. – Gordon Davisson Mar 4 '11 at 3:36
    
Absolutely stellar answer man. Kudos. – peelman Mar 4 '11 at 14:43

I have a exec file that is basically a self hosting service. It triggers without problems when I run it from Terminal with the code /Users/user/Public/node_modules/codem-transcode/bin/codem-transcode -c /Users/user/Public/tmp/config.json

So I created a plist script that I want to run on startup, and I stored it in the LaunchAgent folder. Upon running it, I get the "No such file or directory" error.

Here is a picture showing almost all the information I have

All the information

And here is the plist code

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">

<plist version="1.0">
    <dict>
        <key>KeepAlive</key>
        <dict>
            <key>SuccessfulExit</key>
            <false/>
        </dict>
        <key>Label</key>
        <string>com.wolftech.transcode.job</string>
        <key>RunAtLoad</key>
        <true/>
        <key>StandardErrorPath</key>
        <string>/tmp/com.wolftech.transcode.job.err</string>
        <key>StandardOutPath</key>
        <string>/tmp/com.wolftech.transcode.job.out</string>
        <key>StartInterval</key>
        <integer>60</integer>
        <key>ProgramArguments</key>
        <array>
            <string>/Users/user/Public/node_modules/codem-transcode/bin/codem-transcode -c /Users/user/Public/tmp/config.json</string>
        </array>
    </dict>
</plist>
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .