Does "do shell script" wait? (quasi-noob alert)

when you use the “do shell script” command in applescript does the script wait for whatever command you typed to finish before moving on? or does it just execute whatever you told it to and continue on with the rest of the script?

does setting a variable to do shell script make it wait?

set reply to do shell script "osascript /library/camerabackup/beta3.5.scpt"

As with many things, the answer is ‘it depends’.

By default, AppleScript will wait for the shell script to finish before continuing. This is because it assigns the output of the shell command to the result so you can assign it to a variable (as in your example ‘set reply to do shell script…’)

If AppleScript didn’t wait for the shell script to finish there would be no way for you to use the ‘reply’ variable.

However, if you want to continue immediately you can do so (hence the ‘depends’). Using normal shell techniques you can suppress command output and run the shell command in the background, which allows AppleScript to continue while the shell script runs in the background:

do shell script "sleep 10 > /dev/null 2>&1 &"

You should hear two beeps while the sleep command runs in the background (i.e. doesn’t add a 10 second delay between beeps). The ‘> /dev/null 2>&1’ part suppresses command output (technically it sends stdout to /dev/null and sends stderr to the same place) and the ‘&’ tells the shell script to run in the background.

Thanx. That helped a bunch.