Shell script from Applescript
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.