Execute a shell command in a separate window under Linux

Hi,

I’m trying to execute Clonezilla from within the Xojo’s shell class. It kind of works, but the desktop app just sits until the command finishes; I’d like to show the standard Clonezilla progress instead (i.e. my app lacks a Terminal window).
So I’m trying to tell the shell to open a true Terminal window in which to execute the command.
Being far from an expert in Linux, I’ve not managed to find which terms explain why Xojo’s shells won’t show a “terminal view” compatible with “progress dialogs”. By searching on the Internet, I came across commands such as “gnome-terminal”, “xterm”, “x-terminal-emulator” and “konsole”, meant to open another terminal window, but those aren’t recognized in the Unix environment I’m using (Parted Magic, to mention it).

Any advice, please?

Have you tried changing the Shell.ExecuteMode to Shell.ExecuteModes.Asynchronous to see if the progress is being streamed in the DataAvailable event?

If it is, then you could show those progress messages in a TextArea in your app.

This doesn’t exactly answer your question about how to open a separate “true Terminal window” and execute a command in that window, but it should solve the problem in a different way.

Thanks. Yes, I’m already doing that (showing everything received in DataAvailable in a TextArea).
The problem that I need to solve is exactly what a true terminal window would do as opposed to a Xojo shell: interpreting special commands.
Here’s a screenshot of Clonezilla in action:


Progress bars are updated because “some commands” tell the Terminal window to redraw some places. So, yes, I could probably learn from those commands (that appear as unprintable characters in the DataAvailable event) and make my own “progress system” with these strings, but it would be a huge work that should be solvable by just throwing the command to another Terminal instance/window.

Ahh, I didn’t realize that the Clonezilla terminal window was that complex.

Sorry, I don’t have enough Linux experience to offer any real expertise, but in the interest of learning, I’m curious if this works.

Create a shell script to launch Clonezilla with whatever arguments you pass and then create a .desktop file (this is new to me) and the use FolderItem.Open to launch it.


This was just asking ChatGPT about creating a hello world script that would launch in a terminal by double clicking it. I know that people have mixed feelings about AI generated solutions, but hopefully it could help.

1 Like

Thank you.
I won’t be able to test it before next Monday, so I’ll report how it works at that date.

So, I have tried your solution, but it doesn’t work fully. While the “.desktop” file is correctly created, the user still has to double click the file to launch it.
I tried the following means of opening the “.desktop” file:
1: using Xojo’s FolderItem.Open method. This fails silently.
2: using the shell, passing the shell path of the file. I’m getting an error “[desktop: unrecognized command”; it looks like the shell tries to interpret the “.desktop” file like a script.

It looks close… Any idea?

Are you able to launch the .desktop file in a normal terminal?

I can double click on the file and it launches in a new terminal window, but I’ve not checked opening the file from within an existing terminal window.
My goal is to launch the script without the user needing to double click the file.

I’m curious if the path just wasn’t escaped correctly when you tried to run it in a shell.

That’s unlikely, since the shell tries to execute the “.desktop” file as a script file (so it gets the correct path, just doesn’t launch it as a “.desktop file”).

I wouldn’t be surprised if this is a security measure.

And I’d agree, but it shouldn’t be a security breach to be able to execute commands in a separate terminal window from a Xojo shell either.

Doing a little research, it looks like clonezilla uses partclone, ntfsclone, and dd under the hood and that each sends output that you could possibly parse.

Partclone for instance has output that looks like this:

[XX%] Copying XX MB, XX MB/min, ETA: XX:XX

Which would be relatively easy to parse with regex.

1 Like

Thanks. I’ve managed to make the colours working and showing the progress using a progress bar and labels.
There are still escape sequences that I can’t figure out how to interpret and for which I can’t seem to find documentation, but I’ll try without supporting them if I don’t find them necessary.