Oh!!! I just realized: Terminal.app is itself an application. I just ran this:
tell application "Terminal"
launch
ignoring application responses
do script "system_profiler"
do script "man perl"
do script "man perl"
do script "man perl"
end ignoring
end tell
It opened up 5 windows, (it shoudn’t have opened the first, blank one, since I used “launch” rather than “activate”). In any case, the three man commands very quickly printed to screen in their seperate windows even though the notoriously slow system_profiler command was finished yet.
The one problem is automatically quiting Terminal when it’s done. Since you’re not getting any feedback, you can’t know when its processes are over, and when you call “quit” before Terminal is done doing its thing, a dialog pops up listing the running processes. Looking in the dictionary, I see that Terminal windows have a “busy” boolean. If your main script is a script application, you could save it as a “stay open” script, with this idle handler:
on idle
tell application "Terminal"
repeat with i from 1 to count of windows
if (busy of window i) then return 1 --> go idle for a second
end repeat
-- if we're here, then all windows were finished
--
quit
end tell
-- if we're here, then the stay-open script can itself quit
--
quit
end idle
The above assumes, of course, that all calls made to Terminal are the kind that execute and then finish, unlike my “man” examples above, which wait for interactive commands from the user.
If you’re working with just a compiled script, (perhaps called via the Script Menu), then the idle handler isn’t available to you. Here is an alternative:
-- ... the main part of your script here ...
-- and now you're all done, so:
tell application "Terminal"
repeat with i from 1 to count of windows
repeat
if (busy of window i) then
delay 1 --> go idle for a second
else
exit repeat
end if
end repeat
end repeat
-- if we're here, then all windows were finished
--
quit
end tell