How to run a shell script from an AppleScript

applescriptmacosshellshell-script

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?

Best Answer

Command Line
chmod a+x myShellScript.sh

Or

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

Plus: add shebang to top of shell script

myShellScript.sh
#!/bin/bash

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

Related Question