I'm using osascript to display dialog box from bash script, but it's blocking the script, until i press the 'ok' button.

I wonder if there's a way to make this display window asynchronous.

osascript -e 'tell app "System Events" to display dialog "'"${msg}"'"'

This means that the script will continue running and the osascript will run on the background.


You can add ampersand (&) at the end of the line. Quote from bashitout:

A single ampersand & can often be found at the end of a command.

 ./myscript.py & 

This trailing ampersand directs the shell to run the command in the background, that is, it is forked and run in a separate sub-shell, as a job, asynchronously. The shell will immediately return the return status of 0 for true and continue as normal, either processing further commands in a script or returning the cursor focus back to the user in a Linux terminal.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .