• 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: Creating an environment variable from AppleScript
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Creating an environment variable from AppleScript


  • Subject: Re: Creating an environment variable from AppleScript
  • From: Philip Aker <email@hidden>
  • Date: Mon, 09 Oct 2006 22:14:48 -0700

On 2006-10-09, at 09:09:28, Mark J. Reed wrote:

On 10/9/06, Philip Aker <email@hidden> wrote:
If you want easy control, use Tcl to coordinate:

I fail to see what's so easy about using TCL to run an AppleScript so that you can take the output and feed it to Perl;

Hold on there Quickdraw,

In the first place, I totally agreed with your post:

That's been my experience as well.


Secondly, Kumar wrote:

The “system” function in Perl cannot catch the values returned from AppleScript (by “return” statement).

My code proved that it's not only possible to get return values from an osascript call but also to pass them around to other calls (perl in this case).


Thirdly, my code proves that Tcl can snag stdout from it's exec'd perl call.

Fourthly, if one does have to mix 'n' match tools, Tcl (not TCL BTW) is really the language you should be thinking about. Tool Command Language lives up to its name.


it seems like wasted overhead. I'm particularly not fond of the part where you take the output of the AS and store it in a TCL varaible and pass it on the command line to Perl, since that introduces complications such as a size limit.

Prove it.

Personally, I think it would be a Perl problem (4096 UniChar buffer or something like that) on OS X 10.2 or earlier because I had to fix an NSTask for that problem way back when. But it disappeared in 10.3. It's most certainly NOT a Tcl limitation.


In general, if you've got essentially arbitrary string data, you're better off using I/O (pipes if you can, files if you must) than command line arguments.

I'f you're doing part of the job with perl and part with applescript, just run whichever one does the first part of the job and let it start up the other as needed. I see no need to introduce yet a third interpreter to the mix. (Well, I guess that's unavoidable in the case of calling Perl from AppleScript, since the only way I know of to do that inserts the shell in between them...) Although, if a pipeline model is appropriate, you could use the shell to set it up:

#!/bin/sh
osascript -f myAppleScript.as | perl myPerlScript.pl

That won't work if the perl needs to interact with the user via stdin/stdout, etc., but under the right conditions it could be the simplest answer.

Philip Aker email@hidden


_______________________________________________ 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: Creating an environment variable from AppleScript (From: Steve Hayman <email@hidden>)
 >RE: Creating an environment variable from AppleScript (From: "Kumar Shailove" <email@hidden>)
 >Re: Creating an environment variable from AppleScript (From: "Mark J. Reed" <email@hidden>)
 >Re: Creating an environment variable from AppleScript (From: Philip Aker <email@hidden>)
 >Re: Creating an environment variable from AppleScript (From: "Mark J. Reed" <email@hidden>)

  • Prev by Date: Re: Creating an environment variable from AppleScript
  • Next by Date: Re: Renaming a copied file with Finder
  • Previous by thread: Re: Creating an environment variable from AppleScript
  • Next by thread: Re: Creating an environment variable from AppleScript
  • Index(es):
    • Date
    • Thread