I am running my manual backups with a shell script that asks me for a password. However, when I open the script from the Finder, it terminates immediately.

How can I get a script to run interactively when double clicking on it in Finder?


1 Answer 1


For a bash script to work from finder, it has to have the .command extension

For example, I created the following script to use sudo to ask for a password and then to output a welcome message, then "wait" to simulate execution time:

sudo echo "Welcome to Ask Different"
sleep 10
exit 0

I saved it as test.command. You also have to make it executable: chmod +x test.command

Here's the result of clicking on the script:

enter image description here

  • Turns out, the Terminal setting 'Close if shell exited cleanly' does not keep the window open if the script exited non-zero. Entirely different problem. The .command part does not seem to make any difference at all. So, mea culpa, should have worked perfectly fine in the first place, if I hadn't been so stupid 😀 Nov 9, 2016 at 17:56

You must log in to answer this question.

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