If you pass System.out
and System.err
to consumeProcessOutput()
, the output and error streams will both printed out automatically. If you want to capture it, pass in your own output steams:
def out = new ByteArrayOutputStream()
def err = new ByteArrayOutputStream()
def proc = command.execute()
proc.consumeProcessOutput(out, err)
proc.waitFor()
println "error stream was ${err.toString()}"