Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: cron/Launchd Editor
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: cron/Launchd Editor



Phillip,

On Sep 17, 2009, at 11:09 PM, Philip Aker wrote:

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


Now we're getting somewhere.

I modified your script - For some reason .scpt's don't behave well with Snow Leopard. So went back to .app. The "/usr/bin/osascript" didn't work so removed it.

Here's the plist as IT WORKS.

<?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.playsound</string>
<key>Program</key>
<string>/bin/sh</string>
<key>ProgramArguments</key>
<array>
<string>sh</string>
<string>-c</string>
<string>/Library/Scripts/Universal\ Scripts/playMantelSound.app</string>
</array>
<key>StartCalendarInterval</key>
<dict>
<key>Minute</key>
<integer>0</integer>
</dict>
</dict>
</plist>

Many THANKS, now on to the rest of the plists.



Bob Poland - Fort Collins, CO



 _______________________________________________
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

References: 
 >cron/Launchd Editor (From: Robert Poland <email@hidden>)
 >Re: cron/Launchd Editor (From: Philip Aker <email@hidden>)
 >Re: cron/Launchd Editor (From: Robert Poland <email@hidden>)
 >Re: cron/Launchd Editor (From: Philip Aker <email@hidden>)
 >Re: cron/Launchd Editor (From: Robert Poland <email@hidden>)
 >Re: cron/Launchd Editor (From: Tom Robinson <email@hidden>)
 >Re: cron/Launchd Editor (From: Philip Aker <email@hidden>)
 >Re: cron/Launchd Editor (From: Robert Poland <email@hidden>)
 >Re: cron/Launchd Editor (From: Philip Aker <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.