Created
May 12, 2018 22:04
-
-
Save byjg/80eb3129bfe703658708b93c9ad3d261 to your computer and use it in GitHub Desktop.
Run Shell Script from 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
// Parameters | |
def cmd = "ls -la" | |
def workdir = "/home/" | |
// Code | |
def sout = new StringBuilder(), serr = new StringBuilder() | |
def proc = cmd.execute(null, new File(workdir)) | |
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