Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Applications > Applescript - wait for other script to finish

Applescript - wait for other script to finish
Thread Tools
Junior Member
Join Date: Dec 2006
Status: Offline
Reply With Quote
Apr 9, 2007, 10:47 AM
 
Hello...New to Macs and applescript.

I have one script that calls another script:
code:
do shell script "open /path/to/otherscript.app"

I'd like the first script to wait until the otherscript.app finishes.

I've experimented with the wait command but can't get it working. The delay command seems a bit inelegant, especially since the otherscript.app is on a remote server and I don't know how fast or slow their connection will be.

Any suggestions?
     
Grizzled Veteran
Join Date: Mar 2004
Status: Offline
Reply With Quote
Apr 9, 2007, 11:59 AM
 
Originally Posted by opus_az View Post
I have one script that calls another script:
code:
do shell script "open /path/to/otherscript.app"

I'd like the first script to wait until the otherscript.app finishes.
I've experimented with the wait command but can't get it working.
The delay command seems a bit inelegant.

In order for wait to function as you'd expect, the script needs to "fork-off" some
background job(s) which run(s) as child process(es). The way to do that in a pure
shell script is to put an ampersand on any lines which spawns such subprocesses:

#!/bin/bash
/path/to/some/command &
/path/to/another/command &
wait # waits for all of the above threads to terminate before continuing.

But since AppleScript is involved here, I'm not sure exactly how to do that.
(I'm basically just trying to clear up how "wait" is supposed to work). But...
if using AppleScript isn't vital to the task at hand, I'd say maybe try doing
the whole thing in Bash.
-HI-
     
opus_az  (op)
Junior Member
Join Date: Dec 2006
Status: Offline
Reply With Quote
Apr 9, 2007, 12:19 PM
 
Originally Posted by Hal Itosis View Post
if using AppleScript isn't vital to the task at hand, I'd say maybe try doing
the whole thing in Bash.
Bash would be a learning curve but I assume I'd need to get there sooner or later. So, off I go...

Thanks.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 04:14 AM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2