• 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: Scripting Terminal
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Scripting Terminal


  • Subject: Re: Scripting Terminal
  • From: Axel Luttgens <email@hidden>
  • Date: Fri, 25 Jun 2010 11:46:28 +0200

Le 25 juin 2010 à 02:11:35, Paul Scott a écrit :

> Why doesn't this work?
>
> tell application "Terminal"
>    tell front window
>        set t to selected tab
>        do script "1G" in t
>        set s to contents of t
>        display dialog s
>    end tell
> end tell

Hello Paul,

Looking at Terminal's dictionary, "contents" appears only as a property of a tab; that is, neither a window nor the application itself knows anything about "contents".

As a result, when asking for
	contents of <variable>
you are just applying AppleScript's "contents" keyword to a variable.


> But this does:
>
> tell application "Terminal"
>    tell front window
>        do script "1G" in selected tab
>        set s to contents of selected tab
>        display dialog s
>    end tell
> end tell

Well, yes, because here you are providing the context of a tab of a window of the application: "contents" receives the intended meaning ('pcnt').

BTW, here again, it is worth to check whether that intermediary "t" variable is really needed; "current tab" is probably the most efficient way to access the current tab.
If your concern was to avoid typing, this should be OK as well:

	tell application "Terminal"
		tell front window
			tell selected tab
				do script "1G" in it
				set s to contents
			end tell
		end tell
		display dialog s
	end tell

HTH,
Axel

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Scripting Terminal
      • From: Paul Scott <email@hidden>
References: 
 >Scripting Terminal (From: Paul Scott <email@hidden>)

  • Prev by Date: Re: *** OUT ***AppleScript-Users Digest, Vol 7, Issue 333
  • Next by Date: Problem with unix sips
  • Previous by thread: Re: Scripting Terminal
  • Next by thread: Re: Scripting Terminal
  • Index(es):
    • Date
    • Thread