• 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: variable to shell script
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: variable to shell script


  • Subject: Re: variable to shell script
  • From: Gnarlodious <email@hidden>
  • Date: Fri, 14 May 2004 11:45:41 -0600

You don't actually pass a variable to a shell script, you assemble it as a
string and send the string to shell:

-- extract XML key

set XMLfile to "/Library/Preferences/SystemConfiguration/preferences.plist"
set keyName to "LocalHostName"

do shell script "sed -n '/" & keyName &
"/{n;s/[^t]*<string>\\(.*\\)<\\/string>/\\1/p;}' " & XMLfile


Here's another method useful for multiple instances of the same variable:

file=/Library/Preferences/SystemConfiguration/preferences.plist;
key=LocalHostName;
sed -n '/$key/{n;s/[^t]*<string>\\(.*\\)<\\/string>/\\1/p;}' $file


You can reuse $key and $file as many times as you want as long as it is in
the same shell command.

the above example is strictly text, it won't run as is in Applescript.

-- Gnarlie
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.


  • Prev by Date: Re: Finder doesn't understand the sort message
  • Next by Date: Re: panther weirdness
  • Previous by thread: variable to shell script
  • Next by thread: Mail Script
  • Index(es):
    • Date
    • Thread