Skip to main content
Question

osascript variable


Forum|alt.badge.img+12

Okay I am trying what I thought would not be difficult. I see many articles showing how to use shell variable in osascript what I want is the opposite. I want to move a osascript variable out to a shell script.

So lets say I have this.
osascript<<END display dialog "Are you ready to begin the installer" buttons {"Yes", "No"} set the answer to the button returned of the result
END

How do I get answer out of the osascript into my shell. I have tried the following

Result=$(/usr/bin/osascript -e 'display dialog "Are you ready to begin the installer" buttons {"Yes", "No"}')

echo “${Results}”

what is echoed back is ""

The assistance of the community is appreciated.

3 replies

Forum|alt.badge.img+13
  • Contributor
  • 157 replies
  • August 13, 2014

Not sure about osascript, but you can try using cocoadialog with the "yesno-msgbox" option.


mm2270
Forum|alt.badge.img+16
  • Legendary Contributor
  • 7880 replies
  • August 13, 2014
#!/bin/sh

Result=$(/usr/bin/osascript<<END
tell application "System Events"
activate
set the answer to the button returned of (display dialog "Are you ready to begin the installer" buttons {"Yes", "No"})
end tell
END)

echo "The button clicked was: $Result"

bentoms
Forum|alt.badge.img+35
  • Legendary Contributor
  • 4331 replies
  • August 13, 2014

@ifbell, your echoing out the $Results variable.. But are setting the $Result variable.

So that little "s" may have been it.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings