• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Fwd: Script to run a command in new Terminal window works un-reliably.
[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.


  • 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


  • Follow-Ups:
    • Re: Fwd: Script to run a command in new Terminal window works un-reliably.
      • From: dev_sleidy <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>)

  • Prev by Date: getting file info
  • Next by Date: Re: getting file info
  • Previous by thread: Re: Script to run a command in new Terminal window works un-reliably.
  • Next by thread: Re: Fwd: Script to run a command in new Terminal window works un-reliably.
  • Index(es):
    • Date
    • Thread