Sep212012

How do I input the response from an AppleScript dialogue into a shell script?

David Hallengren asks:

I am trying to use the textual response from an AppleScript dialogue in a shell script command within Applescript. My script at the moment looks like this, where NAME is the response from the dialogue:

set dd to display dialog “What is your name?” default answer ” ”
do shell script “say Welcome NAME”

 


Browser: Chrome 21
System: Mac
Tagged: ,

Comments for this Question are closed.

If you are looking for help, please ask a new question here.

We will be happy to help you!

2 Answers -

0 votes

Mike

September 23, 2012

The first things that come to mind
(1) your line reads “set dd to” which means you do net SET the variable NAME you try to output in the shell part of the script
(2) “dd” is an actual shell command, you should never use such “conflicting” names when your AppleScript at some point goes into a shell command ~ it’s asking for trouble.
(3) in a shell script variables have to be stated outside the quotes so the line would have to be something like: do shell script “say ‘Welcome ‘ & NAME & ‘!’”

0 votes

sojourner

September 28, 2012

set dd to text returned of (display dialog “What is your name?” default answer ” ”)
do shell script “say Welcome ” & dd