• 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: Christopher Nebel <email@hidden>
  • Date: Mon, 9 Oct 2006 09:18:42 -0700

On Oct 8, 2006, at 11:06 PM, Kumar Shailove wrote:
I have written a utility script using AppleScript which is being called from within a Perl Script using “system” function.

The “system” function in Perl cannot catch the values returned from AppleScript (by “return” statement). So as a solution to this problem I though of setting an environment variable from AppleScript which can later be used by that Perl script; but that did not work.


Can you think of an alternative solution to this? The worst one, that I though of is to redirect the output of AppleScript to a text file and then reading this value from the Perl Script.

Sure -- use one of the other Perl "execute" functions that lets you capture the output, such as backticks (`blah`), also known as qx//:


	$hello = `osascript -e 'return "hello world"'`
	$hello = qx/osascript -e 'return "hello world"'/

Or, if you need more control, use "open" with a pipe:

	open(F, "osascript -e 'return "hello word"' |");
	while (<F>)
	{
		print $_;
	}

Even more alternatively, don't use AppleScript at all -- use Mac::Glue, or the lower-level Mac::AppleEvents.


--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: Creating an environment variable from AppleScript (From: "Kumar Shailove" <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