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>
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.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments