• 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: Steve Hayman <email@hidden>
  • Date: Fri, 6 Oct 2006 12:01:20 -0400

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: "Kumar Shailove" <email@hidden>
References: 
 >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: Creating an environment variable from AppleScript
  • Previous by thread: Re: Creating an environment variable from AppleScript
  • Next by thread: RE: Creating an environment variable from AppleScript
  • Index(es):
    • Date
    • Thread