Display Terminal window while running .command scripts from a Xojo app

Hi there,

I recently moved my dev environment to OS X Mojave from Sierra, and I’m noticing that when I execute a .command script from a Xojo app built on Mojave, the terminal window does not appear and show script output. The same code built with the same version of Xojo on Sierra would display the terminal window during runtime.

The script still executes in the background, but with this particular application it’s important to be able to see progress in the terminal output.

I had been using f.Launch previously when this worked on Sierra. I tried f.Open with the same result. I have also tried sh.Execute, as seen here:


// Define Resources Folder
Var ResFolder as FolderItem
ResFolder = SpecialFolder.Resources

Var MainScript As FolderItem
//Location of MainScript in Resources Folder
MainScript = ResFolder.Child(“PT_Build_Loader_Script.command”)

dim sh as new shell
sh.mode = 1

sh.Execute("open -n " + MainScript.ShellPath)


I’m pretty sure I’m doing that one wrong as I could not get the script to fire off at all with that one. f.launch is what was working before in Sierra. Like this:


// Define Resources Folder
Var ResFolder as FolderItem
ResFolder = SpecialFolder.Resources

Var MainScript As FolderItem
//Location of MainScript in Resources Folder
MainScript = ResFolder.Child(“PT_Build_Loader_Script.command”)

// Execute Main Script
MainScript.Launch


But now, no terminal visibility.

Any idea how I can overcome this?

I no longer have a Sierra boot drive to build from so I am stuck. I did try High Sierra and see the same thing. Also went back a few versions with Xojo to be sure, but apparently this is some interaction between Xojo and the OS version.

If I simply double-click the .command file, the terminal window does open as before. This problem only occurs when executing the .command file from my Xojo app. Also, builds built on Sierra behave properly when run on Mojave or High Sierra.

Thanks for reading. Any help is much appreciated.

Kind regards,
Jim

You could try using a Shell in interactive mode which will fire the DataAvailable event with the output from the script. You could then add that data to a TextArea which would show your progress.

Thanks so much, Wayne! Eventually I’d love to have the output in the app, and although that is beyond my current abilities, your suggestion got me looking in the right place. The sh.Execute command is the ticket but I had the syntax wrong before. This is what worked:


DIM sh As new Shell
sh.Execute “open " + MainScript.ShellPath + " -a Terminal”


Adding the " -a Terminal" at the end made it go. Now a terminal output appears just as if the .command script had been opened from the Finder.

Thanks again!

1 Like