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

David Hallengren September 21, 2012
Pinterest Stumbleupon Whatsapp

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”

 

Ads by Google

  1. sojourner
    September 28, 2012 at 2:19 am

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

  2. Mike
    September 23, 2012 at 7:46 am

    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 & '!'"