• 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: Exporting shell variables to AppleScripts
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Exporting shell variables to AppleScripts


  • Subject: Re: Exporting shell variables to AppleScripts
  • From: Steve Hayman <email@hidden>
  • Date: Wed, 19 Sep 2007 22:55:54 -0400

Also keep in mind that environment variables are passed to child processes, but cannot be handed back to a parent. So setting an environment variable in a shell in Terminal is going to have no effect on what system attributes you see in Script Editor, since Terminal is not the parent of Script Editor.

However if you set an environment variable in the terminal, and call osascript from in there, it will see the new value since osascript is a child of the shell that set the variable.

e.g. in Terminal you can set an environment variable - which affects the environment of that shell process - and then run osascript, and since it's a child of the shell, it will see the environment variable you set.


$ FOO=BAR export FOO $ osascript -e 'system attribute "FOO" ' BAR


The original poster asked about exporting shell script variables to AppleScripts. So this is one way. Another way is to pass extra parameters directly to osascript on the command line, where they can be picked up as parameters to the "run" handler. Take a look at "man osascript" for an example of this (look for the "on run argv" part.)


If you want to pass shell variables to a script someone is going to double-click on, that would be trickier.






_______________________________________________ Do not post admin requests to the list. They will be ignored. AppleScript-Users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden
References: 
 >Exporting shell variables to AppleScripts (From: Mike <email@hidden>)
 >Re: Exporting shell variables to AppleScripts (From: Brian Johnson <email@hidden>)
 >Re: Exporting shell variables to AppleScripts (From: "Mark J. Reed" <email@hidden>)
 >Re: Exporting shell variables to AppleScripts (From: Steve Hayman <email@hidden>)

  • Prev by Date: Re: Exporting shell variables to AppleScripts
  • Next by Date: Re: Exporting shell variables to AppleScripts
  • Previous by thread: Re: Exporting shell variables to AppleScripts
  • Next by thread: Re: Exporting shell variables to AppleScripts
  • Index(es):
    • Date
    • Thread