Shell script from Applescript This has been driving me crazy. I have a script which is an executable within /usr/local/bin/, which works perfectly in Terminal, but I am unable to get Applescript to call it:

RunShell("estc R505")

on RunShell(oscript)
    do shell script oscript
end RunShell


doesn't do a thing. I have tried giving the actual location /usr/local/bin/estcinstead, and calling it in bash with bash or sh... nothing works. It should return a text string, and works perfectly in terminal.
In Script Editor, if you run the following AppleScript command:

do shell script "echo $PATH"


You'll see how the PATH is defined to the do shell script command:

"/usr/bin:/bin:/usr/sbin:/sbin"


You need to include the fully qualified pathname to any executable that's not in the PATH, shown above, in order for it to work in an AppleScript do shell script command.



Another option is to add an export PATH command to the do shell script command, e.g.:

set exportPath to "export PATH=$PATH:/usr/local/bin:/opt/X11/bin:"


And in your case, use it as, e.g.:

RunShell("estc R505")

on RunShell(oscript)
    set exportPath to "export PATH=$PATH:/usr/local/bin:/opt/X11/bin:; "
    do shell script exportPath &amp; oscript
end RunShell


Obviously adjust the ... portion of export PATH=$PATH:... to reflect your actual PATH that's not included in the default PATH passed to the do shell script command as shown further above.