Re: Creating an environment variable from AppleScript
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