• 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
Re: New window in Terminal.app
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: New window in Terminal.app


  • Subject: Re: New window in Terminal.app
  • From: Andrew Oliver <email@hidden>
  • Date: Sun, 30 Jan 2005 12:12:02 -0800

On 1/30/05 10:15 AM, "Gnarlodious" <email@hidden> wrote:

> Entity Jonathan Levi, M.D. spoke thus:
>
>> tell application "System Events" to set terminalOn to (exists process
>> "Terminal")
>> if (terminalOn) then
>> tell application "Terminal" to do script "date"
>> else
>> tell application "Terminal" to do script "date" in front window
>> end if
>
> That's better, thanks, Doc!

I'm sure I missed the discussion of why you need to use terminal.app at all,
rather than the much more reliable 'do shell script', but anyway...

This solution still falls foul of Terminal.app's brain-dead window
targeting.

You have no idea what's going on in the front window. Heck, you might not
even be executing your command on your own machine! - how do you know that
the 'front window' isn't running a ssh session to some other system?, or
tied up running some other script?.

Sure, there's the 'busy' flag for a window, but that only reports local
processes and returns 'false' most of the time (including when ssh'd to
another system).

About the only remotely-reliable way I've found is to check the process list
for the window and then decide whether a new window is needed:

 tell application "Terminal"
   if processes of front window = {"login", "tcsh"} -- adjust as necessary
      -- front window is idle, so do your thang
      do script "blah" in front window
   else
      -- front window is doing something else
      do script "blah"
   end if
 end tell

Because 'front window' is an constantly moving target you need to do a
similar check each time you want to 'do script' (the 'front window' now may
be completely different from the 'front window' when you started your
script). What a PITA.

Just use 'do shell script' and be done with it.

Andrew
:)

 _______________________________________________
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: New window in Terminal.app
      • From: Gnarlodious <email@hidden>
    • Re: New window in Terminal.app
      • From: Doug McNutt <email@hidden>
References: 
 >Re: New window in Terminal.app(Applescript-users Digest, Vol 2, Issue 67) (From: Gnarlodious <email@hidden>)

  • Prev by Date: [ann] DumpAETE
  • Next by Date: Re: sending Apple events between users (Pause iTunes of different user, redux)
  • Previous by thread: Re: New window in Terminal.app(Applescript-users Digest, Vol 2, Issue 67)
  • Next by thread: Re: New window in Terminal.app
  • Index(es):
    • Date
    • Thread