code_junkie

Groovy executing shell commands

Nov 11th, 2011
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. println "ls".execute().text
  2.  
  3. def x = shellDo("ls /tmp/NoFile")
  4. println "out: ${x.out} err:${x.err}"
  5.  
  6. def sout = new StringBuffer(), serr = new StringBuffer()
  7. def proc = 'ls /badDir'.execute()
  8. proc.consumeProcessOutput(sout, serr)
  9. proc.waitForOrKill(1000)
  10. println "out> $sout err> $serr"
  11.  
  12. def proc = "ls".execute()
  13. def b = new StringBuffer()
  14. proc.consumeProcessErrorStream(b)
  15.  
  16. println proc.text
  17. println b.toString()
Add Comment
Please, Sign In to add comment