Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'shell scripts' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
shell scripts
Authored by: hayne on Nov 27, '03 05:01:32PM
You will probably want to put these sorts of things into a shell script rather than just running them on the command line. And if you do so, there is another way that you can get parameters into your AppleScript - use shell variables.

Here's how you would do the example from the hint:

#!/bin/sh

text="Test text"

/usr/bin/osascript <<EOT
tell application "Finder"
activate
set theMessage to "$text"
display dialog theMessage buttons "OK" default button 1
end tell
EOT
I have used the "here document" feature of the shell (with <<EOT) to make the script easier to write and to read.

Of course, you could make the shell variable take its value from the clipboard as in the hint:

text=`/usr/bin/pbpaste`


[ Reply to This | # ]
shell scripts
Authored by: mstillwell on Nov 28, '03 01:46:44AM

I agree that in most cases, it's probably easiest to put $1, $2, etc. directly into the here document. However, here's another idea, from Chris Nebel of AppleScript engineering.

Also note that if you're outputting text from your AppleScript, you'll need to feed it through tr to map the \r's to \n's:


#!/bin/sh

/usr/bin/osascript << END | tr "\r" "\n"

-- your script here

END



[ Reply to This | # ]