• 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: using a shell variable in an osascript line?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: using a shell variable in an osascript line?


  • Subject: Re: using a shell variable in an osascript line?
  • From: "Mark J. Reed" <email@hidden>
  • Date: Fri, 27 Feb 2009 16:15:50 -0500

The variable needs to go into the POSIX "environment" list in order
for "system attribute" to find it.  In sh-derived shells
(bash/ksh/zsh) you can take a regular shell variable and copy it into
the environment by "export"ing it.  In csh-derived shells, regular
shell variables and environment variables are kept separate, with
different commands for setting them ("set" vs "setenv").

You can also put an assignment on a command line to set that value in
the environment only for the duration of the command; such an
assignment will override anything in the environment:

$ export HELLO="World"
$ HELLO="There" osascript -e 'system attribute "HELLO"' 2>/dev/null
There
$ echo "$HELLO"
World

But passing the value as an argument, accessible via the run handler's
parameter list, seems to be the cleanest solution.  Thanks, Skeeve.
 _______________________________________________
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

  • Follow-Ups:
    • Re: using a shell variable in an osascript line?
      • From: LuKreme <email@hidden>
References: 
 >Re: using a shell variable in an osascript line? (From: Matthew Smith <email@hidden>)
 >Re: using a shell variable in an osascript line? (From: Skeeve <email@hidden>)

  • Prev by Date: Re: using a shell variable in an osascript line?
  • Next by Date: Re: AS + MS Word 2008 and vertical alignment in table cells
  • Previous by thread: Re: using a shell variable in an osascript line?
  • Next by thread: Re: using a shell variable in an osascript line?
  • Index(es):
    • Date
    • Thread