Hi all,
Thanks for your
responses.
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.
Thanks
Kumar
From: Steve Hayman
[mailto:email@hidden]
Sent: Friday, October 06, 2006
9:31 PM
To: Kumar
Shailove
Cc: email@hidden
Subject: Re: Creating an
environment variable from AppleScript
On 6-Oct-06, at 6:16 AM, Kumar Shailove
wrote:
I am trying to create an
environment variable with AppleScript. The script is as follows
do shell
script “export retval=1”
I am
executing this script with the osascript command with script file path from
Terminal. But the script is not able to set the environment variable.
You can create an environment variable like that but it will only take
effect for the shell launched by "do shell script" and any processes
that particular script happens to run - but it won't take effect for any other
processes, or any subsequent "do shell scripts".
Environment variables pass from a process to its children, but they do
not pass to other unrelated processes.
So in your case you set the "retval" environment variable for
the shell that do shell script happened to execute, but not for any other
processes so it didn't have the effect you were looking for. For the
same reason, you can't set an environment variable in a shell script that you
execute from a Terminal window and expect it to be set in your Terminal
window's main shell. They don't work that way. (They go "down"
but not "up.")
Can you tell us a little more about what you want to do with this
environment variable? Perhaps we can suggest another approach. For
instance you can write environment vars into ~/.MacOSX/environment.plist and
they will be picked up by all of your processes but only after your next login.