Re: cron/Launchd Editor
Re: cron/Launchd Editor
- Subject: Re: cron/Launchd Editor
- From: Philip Aker <email@hidden>
- Date: Thu, 17 Sep 2009 22:09:59 -0700
On 2009-09-17, at 21:05:41, Robert Poland wrote:
<key>Program</key>
<string>/Library/Scripts/Universal\ Scripts/playMantelSound</string>
<key>ProgramArguments</key>
<array>
<string>/Library/Scripts/Universal\ Scripts/playMantelSound</string>
</array>
What's playMantelSound (shell script? AppleScript?) and why does it pass a parameter of itself to itself?
He's created his plist with some utility. It's looks like it's trying to follow the guidelines but doesn't have it quite right. The parameters are the same as those for <x-man-page://3/execvp> as transcribed for the launchd property list XML format. So the Program should contain the full path to the tool, but the first ProgramArgument should contain only the name of the tool.
It does seem kind of odd not to see a .scpt or .scptd extension, but that's a user preference. However if he's just hiding the extension rather than omitting it entirely, then that will be a problem as well (and possibly the cause of the error he reported previously).
Interesting observation, I have the Finder preferences set to show all Filename Extensions. As you noted these were gotten by the Browse command in Lingon.
I'll try adding .scpt and see if that makes a difference. Didn't seem to help.
Here's the edited script; It is supposed to sound the Mantel sound on the hour every hour.
<?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>Label</key> <string>com.rpoland.playMantelSound</string> <key>OnDemand</key> <false/> <key>Program</key> <string>/Library/Scripts/Universal Scripts/playMantelSound.scpt</string> <key>ProgramArguments</key> <array> <string>playMantelSound</string> </array> <key>StartCalendarInterval</key> <dict> <key>Hour</key> <integer>0</integer> <key>Minute</key> <integer>0</integer> </dict> <key>StartInterval</key> <integer>3600</integer> </dict> </plist>
Here's the console error. 9/17/09 10:04:32 PM com.apple.launchd.peruser.501[159] (com.rpoland.playMantelSound[43107]) posix_spawn("/Library/Scripts/Universal Scripts/playMantelSound.scpt", ...): No such file or directory
I think you haven't followed the documentation or grokked the nature of launchd agents because the example above is still horribly wrong. Firstly, launchd is looking for an _executable_ not a script, so you have to use an executable like osascript to run the script. Secondly, the "Program" and "ProgramArguments" are an XML representation of <x-man-page://3/execvp> and mostly likely written so that they can be loaded into a format suitable for an NSTask-like invocation with a minimum amount of effort. Everyone has to follow that format for this kind of agent. And thirdly, in this case, you only need the StartCalendarInterval for the key/value pair.
The following (save it as "ca.aker.playsound.plist" and remember to 'chown root:wheel'), is something that works OMM. At first, only change "some.scpt" into "playMantelSound.scpt" to check if it works on your setup (I'm on 10.6.1 BTW).
<?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>Label</key> <string>ca.aker.playsound</string> <key>Program</key> <string>/bin/sh</string> <key>ProgramArguments</key> <array> <string>sh</string> <string>-c</string> <string>/usr/bin/osascript /Library/Scripts/Universal\ Scripts/some.scpt</string> </array> <key>StartCalendarInterval</key> <dict> <key>Minute</key> <integer>0</integer> </dict> </dict> </plist>
Since I don't have playMantelSound.scpt, I can only assume that it actually works in Script Editor. The "some.scpt" I used looks like:
say "bob" delay 2
Philip Aker echo email@hidden@nl | tr a-z@. p-za-o.@
Democracy: Two wolves and a sheep voting on lunch.
|
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden