1

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.

  • What is estc, is it a binary executable or a script executable? If the latter and it's calling executables not in the default PATH passed to the do shell script command, then the second portion of my answer should help. BTW What does the estc command do? – user3439894 Jan 14 '18 at 16:05
2

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 & 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.

0

This might work:

do shell script "PATH=/usr/local/bin:$PATH estc R505"

You must log in to answer this question.

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