Grab command line mode output with Java ProcessBuilder

All about Mac OS portage
Post Reply
dreiländereck
Posts: 15
Joined: Sun Feb 28, 2021 9:06 am

Grab command line mode output with Java ProcessBuilder

Post 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?
Regards Sebastian
WargodHernandez
Posts: 187
Joined: Tue Mar 05, 2019 3:59 pm

Re: Grab command line mode output with Java ProcessBuilder

Post 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?
dreiländereck
Posts: 15
Joined: Sun Feb 28, 2021 9:06 am

Re: Grab command line mode output with Java ProcessBuilder

Post 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"
Regards Sebastian
WargodHernandez
Posts: 187
Joined: Tue Mar 05, 2019 3:59 pm

Re: Grab command line mode output with Java ProcessBuilder

Post 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.
dreiländereck
Posts: 15
Joined: Sun Feb 28, 2021 9:06 am

Re: Grab command line mode output with Java ProcessBuilder

Post 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
Regards Sebastian
WargodHernandez
Posts: 187
Joined: Tue Mar 05, 2019 3:59 pm

Re: Grab command line mode output with Java ProcessBuilder

Post 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
dreiländereck
Posts: 15
Joined: Sun Feb 28, 2021 9:06 am

Re: Grab command line mode output with Java ProcessBuilder

Post 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.
Regards Sebastian
dreiländereck
Posts: 15
Joined: Sun Feb 28, 2021 9:06 am

Re: Grab command line mode output with Java ProcessBuilder

Post 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.
Regards Sebastian
Post Reply