Applescript errors after sleeping for 5 minutes

So I have a script, which checks to see if an application is running, sleeps for a few minutes and then checks again before continuing it's program. For the sleep, I'm using

"do shell script 'sleep 300'"

If I set the sleep value for anything less than 300 (5 minutes) the scrip executes flawlessly every time. If I set the sleep value for 5 minutes (my ideal value) it errors out. What's weird is that if I put in some dialog box displays at various checkpoints after the sleep, it executes without problem. Is there something important about 5 minute intervals in AppleScript that would be causing this?

MBP, Mac OS X (10.5.5), Powerbook (Nov. 02)

Posted on Oct 20, 2008 9:33 AM

Reply
3 replies

Oct 20, 2008 10:09 AM in response to Tevis Money

What's wrong is that you're going about this the wrong way.

Since you're using do shell script, AppleScript is waiting for a response from the shell. By default every action has a timeout value (so that AppleScript doesn't sit and wait indefinitely for something that's broken). That's what the 5 minutes indicates - up to 5 minutes and you're fine, but after 5 minutes AppleScript is giving up, assuming that the shell command failed.

There are two solutions - one is to change the timeout value, but the better solution is to use AppleScript's sleep rather than call a shell script:

delay 300


Note that you can also use AppleScript date math as well:

delay (5 * minutes)

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Applescript errors after sleeping for 5 minutes

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.