I have built a Xojo program that runs some shell scripts. It was built and works in 10.10.5 system. I had to define the system path in the app.Open event to get the shell script to work in 10.10.5
Dim origPath As String = System.EnvironmentVariable("PATH")
System.EnvironmentVariable("PATH") = "/usr/local/bin:" + origPath
A colleague who is on High Sierra 10.13.5 cannot get the the shell scripts to run, they return “command not found”.
Do I need to define a different system path for High Sierra?
Private Function FindCliApp(cli As String) as FolderItem
dim f as FolderItem
#if TargetMacOS or TargetLinux then
dim sh as new shell
sh.Execute "/bin/bash -lc " + ShellQuote("which " + cli.Trim)
if sh.ErrorCode = 0 then
dim path as string = sh.Result
path = ReplaceLineEndings(path, EndOfLine).Trim
path = path.NthField(EndOfLine, path.CountFields(EndOfLine))
f = new FolderItem(path, FolderItem.PathTypeNative)
end if
#else
#pragma unused cli
#endif
return f
End Function
Private Function ShellQuote(s As String) as String
s = s.ReplaceAll("'", "'\\''")
s = "'" + s + "'"
return s
End Function
Simply put - the Xojo Shell class does NOT inherit the normal Terminal environment. Anything that you want to access on Mac OS will require the full NativePath.
I build a list of my app’s external commands and set constants like:
chmodbin = “/bin/chmod”
I then call out to the command with something like: