Its not the output of binary I need help with, but with passing input to it.
I think I said, "OutputStream to the input of the binary". I am not sure if that's an accurate description.
-----Original Message-----
From: Ryan McKinley [mailto:
[hidden email]]
Sent: Wednesday, September 23, 2009 6:00 PM
To: Commons Users List
Subject: Re: [exec] OutputStream to the input of the exec process
I'm new to commons exec.... but why not just:
DefaultExecutor executor = new DefaultExecutor();
ByteArrayOutputStream out = new ByteArrayOutputStream();
executor.setStreamHandler(new PumpStreamHandler( out ) )
int exitValue = executor.execute(commandLine);
String txt = out.toString();
On Sep 23, 2009, at 8:44 PM, Arun Ramakrishnan wrote:
> 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;
---------------------------------------------------------------------
To unsubscribe, e-mail:
[hidden email]
For additional commands, e-mail:
[hidden email]
---------------------------------------------------------------------
To unsubscribe, e-mail:
[hidden email]
For additional commands, e-mail:
[hidden email]