commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Siegfried Goeschl <siegfried.goes...@it20one.at>
Subject Re: [exec] redirect output via command
Date Fri, 13 Aug 2010 09:14:03 GMT
Hi Thomas,

+) redirection such as "> out.txt" is implemented in the command line 
processor or shell. You would need a batch file to do that (a coule of 
the regression tests are using that redirection)

+) "executor.setStreamHandler(null)" - should give you a NPE. Please 
comment out the line. Without a stream handler you application will block.

+) Another was of getting the output is to use a StreamHandler and pass 
a FileOutputStream.

Cheers,

Siegfried Goeschl

On 13.08.10 00:00, Thomas Tanneberger wrote:
> Hi All,
>
> while I am playing with Apache Common Exec I found out that is it
> obviously not possible to redirect output into a file via command. I
> want to exec cksum file>  file.chsum.txt. I get the output of cksum in
> ecplise but it is not written to disk.
>
> <code>
> public static String CHKSUM_CMD2 = "cksum \"${FILE_NAME}\">  out.txt";
> HashMap<String, String>  options = new HashMap<String, String>();
> CommandLine commandLine = CommandLine.parse(CHKSUM_CMD2);
> options.put("FILE_NAME", fileName);
> commandLine.setSubstitutionMap(options);
> DefaultExecutor executor = new DefaultExecutor();
> executor.setStreamHandler(null);
> executor.execute(commandLine);
> </code>
>
> I suppose that I have to capture the output and write it to disk
> afterwards. Or is there other solution ahead?
>
> Many thx, Thomas
>
>
> ---------------------------------------------------------------------
> 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