Add Bash variables to “osascript -e” command

When you’re using Bash scripts it’s sometimes necessary to show a window to the user asking for specific information or showing warning through AppleScript.

After a long Google search, I finally found how to add Bash variables directly into a “display dialog” window using the command “osascript-e”.┬áIt is sufficient to use the single quotation mark : ‘$EXAMPLE’

This example will show the Bash variable “$LAST_CONNEXION_DATE” in a window :

osascript -e 'tell app "System Events" to display dialog "Last connextion date : '$LAST_CONNEXION_DATE'" buttons {"Cancel", "Continue"} cancel button "Cancel" default button "Continue"'

2 Replies to “Add Bash variables to “osascript -e” command”

Leave a Reply

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