Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fwd: Script to run a command in new Terminal window works un-reliably.



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:
http://lists.apple.com/mailman/options/applescript-users/email@hidden

This email sent to email@hidden
References: 
 >Script to run a command in new Terminal window works un-reliably. (From: Andrei Tchijov <email@hidden>)
 >Re: Script to run a command in new Terminal window works un-reliably. (From: Andrew Oliver <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.