Hey all
I'm hoping someone out there has learned something useful about launchd, plist's, and timing scripts.
I have a rather simple script that I was trying to make run on a schedule through launchd (15 min to be exact) mainly to get to learn the system.
The general problems... I finally got through it all enough to load the script into launchd through a valid plist ("verified in Lingon" though I don't think was necessary since all Lingon did was add fields withe "false" values). The jist though is the plist file (I've named com.nathan.messagealert.plist to keep the *^#4& formatting going) calls on an Applescript (which runs perfectly fine in the editor or even as an app on startup) which it should then run on a "StartInterval" schedule of 900 sec. Now, I read and found the proper way of making the script an executable file which made it load but it's acting very funny. Remember the time schedule of 15 min I mentioned?? Well, when the script was loaded it kept running and running and running...you get the idea. It wouldn't stop until I killed it.
Any thoughts on why this would react this way? Is a scpt file ok? Does the scpt need a "quit" or "exit" at the end of it? I'm just analyzing the possibilities...
Here is the Applescript scpt file which at the moment has no other properties than just that (is not run only, an app, etc)
And here is the plist file
Again, any input on why this would cause the script to run over and over and over would be greatly appreciated. Thanks!!!
I'm hoping someone out there has learned something useful about launchd, plist's, and timing scripts.
I have a rather simple script that I was trying to make run on a schedule through launchd (15 min to be exact) mainly to get to learn the system.
The general problems... I finally got through it all enough to load the script into launchd through a valid plist ("verified in Lingon" though I don't think was necessary since all Lingon did was add fields withe "false" values). The jist though is the plist file (I've named com.nathan.messagealert.plist to keep the *^#4& formatting going) calls on an Applescript (which runs perfectly fine in the editor or even as an app on startup) which it should then run on a "StartInterval" schedule of 900 sec. Now, I read and found the proper way of making the script an executable file which made it load but it's acting very funny. Remember the time schedule of 15 min I mentioned?? Well, when the script was loaded it kept running and running and running...you get the idea. It wouldn't stop until I killed it.
Any thoughts on why this would react this way? Is a scpt file ok? Does the scpt need a "quit" or "exit" at the end of it? I'm just analyzing the possibilities...
Here is the Applescript scpt file which at the moment has no other properties than just that (is not run only, an app, etc)
Code:
say "Welcome back, Nathan."
tell application "Mail"
repeat with thisAccount in every account
set thisInBox to mailbox named "INBOX" of thisAccount
set thisUnreadCount to unread count of thisInBox
if thisUnreadCount is not 0 then
set unreadMessages to (messages of thisInBox whose read status is false)
if thisUnreadCount > 1 then
set pluralText to "s"
set verbText to "are"
else
set pluralText to ""
set verbText to "is"
end if
set speechCountText to "There " & verbText & " " & thisUnreadCount & " unread message" & pluralText & " in " & (name of thisAccount) & "."
say speechCountText
tell application "Safari"
activate
end tell
end if
end repeat
end tell
And here is the plist file
Code:
<?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>Disabled</key>
<true/>
<key>KeepAlive</key>
<false/>
<key>Label</key>
<string>com.nathan.messagealert</string>
<key>OnDemand</key>
<false/>
<key>Program</key>
<string>/usr/bin/osascript</string>
<key>ProgramArguments</key>
<array>
<string>osascript</string>
<string>/Library/Scripts/MailMessage.scpt</string>
</array>
<key>RunAtLoad</key>
<false/>
<key>StartInterval</key>
<integer>1200</integer>
</dict>
</plist>
Again, any input on why this would cause the script to run over and over and over would be greatly appreciated. Thanks!!!