2

Is there a way to display messages to the MAC desktop from a BASH script? I am writing a terminal window script, that needs to display a message on the MAC desktop. Also if the was a way to open a message box from a BASH script.

Dennis

1
  • Thanks, that looks like it will work. Commented Feb 26, 2015 at 18:35

1 Answer 1

5

Like this:

#!/bin/bash osascript -e 'Tell application "System Events" to display dialog "Some Funky Message"' 

enter image description here

Or, if you want the user to input something and get the result...

#!/bin/bash input=$(osascript -e 'Tell application "System Events" to display dialog "Enter something:" default answer ""' -e 'text returned of result' 2>/dev/null) echo $input 

enter image description here

And, to anticipate your next question, if you want bash variables in the dialog box and also quotes and stuff, you can use this form of sending the script into osascript on its stdin:

#!/bin/bash var=7 input=$(osascript <<EOF Tell application "System Events" to display dialog "Steve's Funky Message ($var) with apostrophe and variable" EOF) 

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.