commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Arun Ramakrishnan <aramakrish...@languageweaver.com>
Subject [exec] OutputStream to the input of the exec process
Date Thu, 24 Sep 2009 00:44:55 GMT
This is a follow up of my previous Question regarding similar topic.

How do i get hold of an outputStream to the input of the binary i am trying to wrap using
Apache Commons Exec ?

I see, then can you tell me whats wrong with this approach ? Nothing seems to go to the input
of tool.exe.

I should probably post on apache commons forums, will do that if i cant get any response here.

I apologise for the groovy code.


import org.apache.commons.exec.*;

String line = "tool.exe" ;
CommandLine commandLine = CommandLine.parse(line);


commandLine.addArgument("engita")
DefaultExecutor executor = new DefaultExecutor();

def os =  new BufferedOutputStream(new ByteArrayOutputStream());

PumpStreamHandler ioh = new PumpStreamHandler();
ioh.setProcessInputStream(os)
ioh.start()
executor.setStreamHandler(ioh)
String s = "hi there \n";
[1..10].each{
os.write(s.getBytes());
}
//os.close();
int exitValue = executor.execute(commandLine);
println " execution started"
println exitValue;

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message