I already have Java code that can handle all the output from stdout and stderr, and that all works fine. It uses getInputStream() and getErrorStream();
If I enter a command like this in a Bash terminal:
export ANDROID_HOME=/usr/local/bin/android-sdk-linux;export PATH=${PATH}:/usr/local/bin/gradle-1.8/bin;cd /var/local/android/dev/GradleHelloWorld;gradle clean
It gets extra output like:
> Loading
>Loading Resolving dependencies ...
>Building
Until it gets the regular "end" output:
:clean UP-TO-DATE
BUILD SUCCESSFUL
Total time: 2 mins 37.424 secs
But after trying many different combinations of, the below, with and without the "-c":
processBuilder = new ProcessBuilder("bash", "-c", sCmd);
proc = rt.exec(new String[] {"/bin/bash", "-c", commandS});
I know those are pretty much the same, but you get the idea. It only shows the "end" result, and not any of the other output before it.
For Windows I can get all the output with no problem, using:
proc = rt.exec("cmd.exe");
and the command string.
I don't know that much about Bash, so is there any other options I can try, or a different Java statement I can use to try to capture all the output using Java?
Aucun commentaire:
Enregistrer un commentaire