open terminal window, wait and then close it

hi there

i’ve written an applescript which opens a terminal window, execute a shellscript and closes the wndow at the end.


tell application "Terminal"
	set myTab to do script "myShellScript.sh"
	repeat until myTab is not busy
	end repeat
	close myTab
end tell

however it does not work as expected: the script does not wait until the shellscript is finished.

what can i do?

thanks, olli

One thing, is you might want to try it with do shell script, not do script. Secondly, you might also try throwing delay 1 into the repeat loop. So it will delay quitting a second for every second the command is still running. Lastly, maybe instead of closing myTab, just use the quit command to quit Terminal.

I don’t work with shell scripts too much, so I can’t guarantee that these solutions will work. But it’s worth a try. :wink:

True, if you want to wait, do this:

do shell script "myShellScript.sh"

thanks for your suggestions. however

do shell script 

doesn’t work as intended: it does not do it’s work in terminal, so i don’t see the progress in the terminal window.

but i’m using the tip with the delay in the loop - and i found the right way to test for teh terminal window beeing busy:

tell application "Terminal"
	set myTab to do script ". p365ago_screens.sh"
	repeat until busy of myTab is false
		delay 1
	end repeat
	display dialog "finished"
end tell

the only thing i now need to find out is, how to close the tab/window. but i guess that’s worth another post (http://macscripter.net/viewtopic.php?pid=126741).

That’s because the command-line should be

sh p365ago_screens.sh