Re: Shell Script Timeout?
Re: Shell Script Timeout?
- Subject: Re: Shell Script Timeout?
- From: Graff <email@hidden>
- Date: Sat, 21 Feb 2004 15:37:53 -0500
The problem is not due to the "do shell script" command, rather it is
due to the System Events application.
You are telling the process iMovie not to worry about the timeout and
it does this without a problem. However, the System Events application
was not "informed" of the change in timeout and seems to be using the
default timeout of 60 seconds when it is waiting for a response from
the iMovie process. Changing the timeout block to wrap the iMovie tell
block seems to fix this:
----------
set seconds_of_importing to 1 * hours
set shell_string to "sleep " & seconds_of_importing
tell application "System Events"
with timeout of (seconds_of_importing + 1 * minutes) seconds
tell process "iMovie"
tell front window
tell group 1
click button "Import"
end tell
end tell
do shell script shell_string
tell front window
tell group 1
click button "Import"
end tell
end tell
end tell
end timeout
end tell
----------
I also added in a safety margin of one minute to the timeout block.
You had the timeout equal to the exact length of the sleep statement.
If the commands in the iMovie tell block were to add even a second or
two more to the total time then the whole thing might timeout early.
Adding in the extra minute to the timeout block gives you some leeway.
From my experiments a "do shell script" command does not need a timeout
statement. I tried sleep statements up to a couple of minutes and had
no problems with the command timing out.
- Ken
On Feb 21, 2004, at 2:39 PM, Glenn Sugden wrote:
Could someone please help me out with this (simple) script?
This script works correctly (when the seconds of importing is small)...
...but the "do shell script" line times-out without the "with timeout"
block...
...and continues to time-out even with the block.
I didn't know that shell scripts would time AppleScript out, but I
guess they do...
...yet isn't this the correct solution?
Thanks - -
::Glenn
---
set seconds_of_importing to (60 * 60) -- 1 hour(s)
set shell_string to "sleep " & seconds_of_importing
tell application "System Events"
tell process "iMovie"
tell front window
tell group 1
click button "Import"
end tell
end tell
with timeout of seconds_of_importing seconds
do shell script shell_string
end timeout
tell front window
tell group 1
click button "Import"
end tell
end tell
end tell
end tell
---
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.