How to run a shell script from an AppleScript? I am using a Mac running OSX Yosemite v.10.10.5.

When I try to run my shell script from my AppleScript, I get the following error message:

Error message at AppleScript Script Editor

error "sh: /Users/path/to/file/myShellScript.sh: Permission denied" number 126


myShellScript.sh

cd /Users/myusername/Git/myproject/
git remote remove origin


myAppleScript.applescript

do shell script "/Users/path/to/file/myShellScript.sh"


What am I doing wrong?
To not get that error, you need to make myShellScript.sh executable.

In a Terminal, use the following command:

chmod u+x /path/to/file/myShellScript.sh


Also, you should add a shebang to the top of the script.

Example: #!/bin/bash

Note: Use the appropriate shebang for the shell you want to process your script.

If you do not want to make the script executable, although I can't see a reason one wouldn't want to, you can run it in AppleScript as in the following example:

do shell script "bash /path/to/file/myShellScript.sh"


Note: If you want to use sh over bash, just substitute it in the command and the shebang.