Hi Thomas,

success stories are always welcome ... :-)

Cheers,

Siegfried Goeschl

On 23.08.10 22:09, Thomas Tanneberger wrote:
Hi Siegfried,

many thx for your advise. The solution is quite simple. You can open a
StreamWriter and write the output directly into. See example below.

<code>
PumpStreamHandler ps = new PumpStreamHandler(new FileOutputStream(
                                "fileName"));
executor.setStreamHandler(ps);
executor.execute(commandLine);
</code>

Thomas

Am Freitag, den 13.08.2010, 11:14 +0200 schrieb Siegfried Goeschl:
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-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



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




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

Reply via email to