Pop-Up Alert in Command line using AppleScript

You can open pop-up alert in command line using AppleScript.

Let Finder or System Events display dialog like this:[1]StackOverflow: How do I make a Mac Terminal pop-up/alert? Applescript? 

osascript -e 'tell app "Finder" to display dialog "Hello World"' 
osascript -e 'tell app "System Events" to display dialog "Hello World"'

You can get the return response like this, too [2]Displaying a dialog box using terminal commands

#!/bin/bash
x=`/usr/bin/osascript <<EOT
tell application "Finder"
	activate
	set myReply to button returned of (display dialog "Here is a dialog box" default button 2 buttons {"button one", "button two", "OK"})
end tell
EOT`
echo 'Button is: '$x
if [[ $x = "OK" ]]; then 
echo 'Shell script continues...'
# Your
# Code
# Here
fi
echo 'Script ends.'

You May Also Like

Leave a Reply

Your email address will not be published. Required fields are marked *