commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Tanneberger <ttann...@gmx.net>
Subject [exec] redirect output via command
Date Thu, 12 Aug 2010 22:00:38 GMT
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


Mime
View raw message