commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Siegfried Goeschl <sgoes...@gmx.at>
Subject Re: How To Get The Output Of A Command Into A String Variable
Date Thu, 23 Dec 2010 14:13:37 GMT
Hi Carlo,

you see the output because it is redirected to stdout.

Can you check

http://commons.apache.org/exec/xref-test/org/apache/commons/exec/DefaultExecutorTest.html



we have a lot of tests (e.g. testExecute()) doing exactly that

Cheers,

Siegfried Goeschl

On 12/23/10 10:36 AM, Carlo Camerino wrote:
> Hi,
>
> good day! is there anyway that I can get the output of a string variable
>
> CommandLine commandLine = new CommandLine("7z");
>          commandLine.addArgument("e");
>          commandLine.addArgument("-psa-
> emp");
>          commandLine.addArgument("-y");
>          commandLine.addArgument("-o<output-folder>");
>          commandLine.addArgument("<file-name-of-zip>")
> DefaultExecutor executor = new DefaultExecutor();
>      int exitValue = executor.execute(commandLine);
>
> i could actually see the result in the console, however, i'm trying to
> find a way in which i can store the result into a string variable
> since
> it is a requirement to store the actual results.
>
> Here is a sample result
>
> Processing archive:<file-name-of-zip>
>
> Extracting<file-name>
> Extracting<file-name>
>
> is there anyway that i can get the outputstream and store it into a
> string variable?
>
> thanks a lot
> carlo
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message