I want to create an executable file that when run will send a popup. I have the code for the popup
osascript -e 'tell app "Finder" to display dialog "message"'
but don't know how to create an executable file.
Write your shell script in a text file, including the shebang.
If you're just using AppleScript, you can use osascript as the shebang:
#!/usr/bin/osascript tell app "Finder" to display dialog "message"
Set the executable bit on the file.
chmod +x /path/to/file
This gives you a file which will run your shell script when opened.
You can save it as a script by putting this in a plaintext file and save it as something like dialog.sh:
#!/bin/bash osascript -e 'tell app "Finder" to display dialog "message"'
Then making the file executable in the terminal by running
chmod +x /path/to/dialog.sh.
Execute in terminal by running