Link to home
Start Free TrialLog in
Avatar of nixj14
nixj14

asked on

Stdout/Stderr of a Process

I want to access the ouput of a command executed within a Process.  The command that I'm looking to capture the output from is:

cmd /c cd /d D:\eclipse\workspace\ANT && cvs -d :pserver:deployer@mitnick.ugs.com:/cvs commit -m warfile D:\eclipse\workspace\ANT/cvsworking/CSS/Resources/Log4j.xml

Basically, I'm extending the ANT CVS task so that I can parse the result and find out what the new version number of the file is.  

Heres a code snippet:

{
  if (project != null) {
    project.log("Execute:CommandLauncher: " +
                            Commandline.toString(cmd), Project.MSG_DEBUG);
  }                            
  return Runtime.getRuntime().exec(cmd, env);
}
Avatar of Venci75
Venci75

use:
Process p = Runtime.getRuntime().exec(cmd, env);
InputStream in = p.getInputStream();

the InputStream in is the output (Stdout) of the process.
ASKER CERTIFIED SOLUTION
Avatar of Igor Bazarny
Igor Bazarny
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of nixj14

ASKER

I apologize that it took so long for me to get back to this, but its been project deployment week.  This response is definitely what I needed.  Have you thought about submitting this Substitute task to Apache?