Re: variable to shell script
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.