Re: Ignore responses from do shell script
Re: Ignore responses from do shell script
- Subject: Re: Ignore responses from do shell script
- From: Phil Stokes <email@hidden>
- Date: Sat, 09 Jul 2016 18:59:15 +0700
I was able to achieve what I wanted thanks to Alex’s tip to re-read the do shell script doc.
The answer is to run the shell command as a background task using the “&” function.
do shell script theCommand & " &> /dev/null &"
That will kick off the shell script and return control to the AppleScript. In my case, I didn’t want the AppleScript to end there because then the user has no way of knowing when or if the shell script completes. To deal with that, I add another do shell script after the first to check when the process is complete:
# run theCommand as background task do shell script theCommand & " &> /dev/null &"
#wait for the task to appear in the process list delay 10
set isDone to false repeat while isDone is false try # we need multiple grep's to stop grep finding its own process in ps do shell script "ps ax | grep -v grep | grep " & theProcessName if the result contains theProcessName then delay 10 end if on error # when the task is done the shell will return an error set isDone to true display dialog "Your task is done!" end try end repeat
Best
phil
|
_______________________________________________
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