Skip to content

Instantly share code, notes, and snippets.

@smola
Created July 8, 2020 09:15
Show Gist options
  • Save smola/2d6b8f8693f6b101f14e3f29927b8ec0 to your computer and use it in GitHub Desktop.
Save smola/2d6b8f8693f6b101f14e3f29927b8ec0 to your computer and use it in GitHub Desktop.
Run a command in Groovy
def run(cmd) {
// author: Bob Herrmann
// source: https://stackoverflow.com/a/159270
def sout = new StringBuilder(), serr = new StringBuilder()
def proc = cmd.execute()
proc.consumeProcessOutput(sout, serr)
proc.waitForOrKill(1000)
println "out> $sout err> $serr"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment