Created
July 8, 2020 09:15
-
-
Save smola/2d6b8f8693f6b101f14e3f29927b8ec0 to your computer and use it in GitHub Desktop.
Run a command in Groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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