Page 1 of 1

Grab command line mode output with Java ProcessBuilder

Posted: Sun Feb 28, 2021 1:26 pm
by dreiländereck
Hello anybody,

does someone has experience in grabbing the command line output with the Java ProcessBuilder API?

I'm playing around with the command line mode and some lines of Java, but couldn't grab the std::cout from cloud compare in command line mode.

Is this possible on windows with powershell?

Re: Grab command line mode output with Java ProcessBuilder

Posted: Mon Mar 01, 2021 4:47 pm
by WargodHernandez
I know for sure the windows output is being sent to the command line correctly so it should be available in powershell. but we only redirect to the console output in -SILENT mode. are you using -SILENT?

Re: Grab command line mode output with Java ProcessBuilder

Posted: Mon Mar 01, 2021 8:54 pm
by dreiländereck
Yes, I did use the

Code: Select all

-SILENT
option.

My command is called this way:

Code: Select all

"open", "-a", "CloudCompare.app", "-n", "--args", "-SILENT", "-NO_TIMESTAMP", "-C_EXPORT_FMT", "LAS", "-O", "/Users/set3/pcl_1.las", "-O", "/Users/set3/pcl_2.las", "-MERGE_CLOUDS"

Re: Grab command line mode output with Java ProcessBuilder

Posted: Mon Mar 01, 2021 9:04 pm
by WargodHernandez
I'm not sure if the silent commands gets redirected on Mac to the standard console, you could run the same command in a terminal to see if it does.

Re: Grab command line mode output with Java ProcessBuilder

Posted: Mon Mar 01, 2021 9:26 pm
by dreiländereck
I copied the files to a shorter folder structure and test it with the terminal command (zsh shell)

Code: Select all

open -a CloudCompare.app --args -NO_TIMESTAMP -C_EXPORT_FMT LAS -O /Users/s/cc/pcl_1.las -O /Users/s/cc/pcl_2.las -MERGE_CLOUDS
It opens the Command Line Mode Window, like the Java approach.

An additional "-SILENT" let the app run in the background, (I can see the merged point cloud), but no output to the console.

Code: Select all

open -a CloudCompare.app --args -SILENT -NO_TIMESTAMP -C_EXPORT_FMT LAS -O /Users/s/cc/pcl_1.las -O /Users/s/cc/pcl_2.las -MERGE_CLOUDS

Re: Grab command line mode output with Java ProcessBuilder

Posted: Mon Mar 01, 2021 9:53 pm
by WargodHernandez
After looking into it, doesn't look like there is a simple solution.

https://stackoverflow.com/questions/601 ... ng-termina

I don't have any Mac systems to test anything on so I believe unless a Mac developer wants to step forward, not sure if this will be fixed

Re: Grab command line mode output with Java ProcessBuilder

Posted: Tue Mar 02, 2021 7:33 pm
by dreiländereck
WargodHernandez wrote: Mon Mar 01, 2021 9:53 pm After looking into it, doesn't look like there is a simple solution.

https://stackoverflow.com/questions/601 ... ng-termina

I don't have any Mac systems to test anything on so I believe unless a Mac developer wants to step forward, not sure if this will be fixed
Man, you made my day, or better evening! With your input, everything becomes clear and the fog is gone away.

I use the following command to access the CloudCompare executable.

Code: Select all

"/Applications/CloudCompare.app/Contents/MacOS/CloudCompare", ...
Now, everything flows to the process input stream. I have to check a threaded version to get the realtime input, but the static input after CloudCompare has finished its work is half of the run.

Re: Grab command line mode output with Java ProcessBuilder

Posted: Wed Mar 03, 2021 10:06 pm
by dreiländereck
WargodHernandez wrote: Mon Mar 01, 2021 9:53 pm After looking into it, doesn't look like there is a simple solution.
You are wright. I take a short dive into a threadded solution for reading the inputstream. But it doesn't work at the moment.

One question there: Flushes CloudCompare the stream buffer after every step, or after finishing all steps at once?

At the moment I got all input stream lines after CloudCompare had done its job.