Fwd: Script to run a command in new Terminal window works un-reliably.
Fwd: Script to run a command in new Terminal window works un-reliably.
- Subject: Fwd: Script to run a command in new Terminal window works un-reliably.
- From: Gnarlodious <email@hidden>
- Date: Thu, 27 Jul 2006 15:10:14 -0600
Andrew Oliver wrote:
>> tell application "Terminal" to do script "command to run"
>
> Unfortunately this method fails if Terminal is running but no
> window is open.
Works just fine here.
This always opens a new window, if Terminal is not running it opens two windows:
tell application "Terminal" to do script "uptime"
This always uses the front window, but errors if no window exists:
tell application "Terminal" to do script "uptime" in front window
This always uses the front window and creates one if it does not exist:
tell application "Terminal"
activate
if (count of windows) is 0 then
do script ""
delay 0.1 -- this delay is apparently not necessary for faster machines
end if
do script "uptime" in front window
end tell
The only unresolved problem is if the window is busy with an open
process or logged into an SSH server. Does anyone know how to evaluate
for these possibilities?
-- Gnarlie
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden