• 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: RegExps in AS
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: RegExps in AS


  • Subject: Re: RegExps in AS
  • From: Christopher Nebel <email@hidden>
  • Date: Sat, 26 Feb 2005 18:45:16 -0800

On Feb 26, 2005, at 9:12 AM, Ihar 'Philips' Filipau wrote:

AS and shell are not inter-mixable. So you cannot open pipeline to external (Unix) application and a-la expect do the processing. Neither you can send AS output to stdout/stderr where it can be further processed by unix tools.

Something like that (wild imagination):
$ echo Hello World | open /somewhere/aaa.scpt | cat >aaa.scpt.output
is not possible.

And reverse (with mythical "send to filedescriptor" operator & other imaginary stuff):
| set a to file descriptor of shell script "tr A-Z a-z | sed s/a/b/"
| send to a "initial value"
| repeat with line read from a
| if -- whatever
| send to stdout line & "\n"
| end if
| send to a "next item"
| end repeat
isn't possible too.


That's be truly cool. Everything would do whatever it does better: file & text handling in shell scripts, GUI integration in AS.

Incorrect, at least partially -- man osascript(1). You can run a script from the shell, and the results will be printed to stdout, as in this example that I occasionally use to find duplicate people in my address book:


osascript -e 'tell app "Address Book" to get the name of every person' | perl -pe 's/, /\n/g' | sort | uniq -d

Now, it's true that it's not ideal: AppleScript doesn't have any idea of incremental output (that is, there's no "print" command that just spits something to stdout; you have to bundle up all your output and return it at the end), nor is there any straightforward way to deal with stdin, nor is there any idea of opening another process as a pipe. These have all been requested before, of course.


--Chris Nebel AppleScript Engineering

_______________________________________________
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


References: 
 >Re: RegExps in AS (From: "Ihar 'Philips' Filipau" <email@hidden>)

  • Prev by Date: Re: What is this?
  • Next by Date: Re: What is this?
  • Previous by thread: Re: RegExps in AS
  • Next by thread: Re: RegExps in AS
  • Index(es):
    • Date
    • Thread