How to run Terminal commands from Finder?
I would like to put a series of Terminal commands into a file, then run the commands by double-clicking on the file in Finder. I've found a number of sources on how to do this on the internet, but nearly all include comments from other users saying "this didn't work for me". I've not found a definitive "this is how to do it".
I created a test file using TextEdit, named it test.command, and saved it to my desktop. The file contains these commands:
!/bin/sh
chmod +x ~/Desktop/test.command
echo "hi there"
echo "hi again"
When I double-click on the file, however, it sometimes just opens in Finder. Other times, I get an error message saying that I do have permission to run the file. I thought the chmod command was supposed to handle the permission, but maybe I'm not using it correctly.
Can anyone help?
iMac, OS X Yosemite (10.10)