• 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: "Kumar Shailove" <email@hidden>
  • Date: Mon, 9 Oct 2006 11:36:56 +0530
  • Thread-topic: Creating an environment variable from AppleScript

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.

 

 

 

 _______________________________________________
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

  • Follow-Ups:
    • Re: Creating an environment variable from AppleScript
      • From: Christopher Nebel <email@hidden>
    • Re: Creating an environment variable from AppleScript
      • From: "Mark J. Reed" <email@hidden>
References: 
 >Re: Creating an environment variable from AppleScript (From: Steve Hayman <email@hidden>)

  • Prev by Date: Re: Backlight using GUI scripting doesn't work...
  • Next by Date: How do I loop through already open psds?
  • Previous by thread: Re: Creating an environment variable from AppleScript
  • Next by thread: Re: Creating an environment variable from AppleScript
  • Index(es):
    • Date
    • Thread