You can get the entire output stream使用.text:
def process = "ls -l".execute() println "Found text ${process.text}"
解决方法
你可以使用waitForProcessOutput,它有两个Appendables(
docs here)
def process = "ls -l".execute() def (output,error) = new StringWriter().with { o -> // For the output new StringWriter().with { e -> // For the error stream process.waitForProcessOutput( o,e ) [ o,e ]*.toString() // Return them both } } // And print them out... println "OUT: $output" println "ERR: $error"