Skip to content

Instantly share code, notes, and snippets.

@byjg
Created May 12, 2018 22:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save byjg/80eb3129bfe703658708b93c9ad3d261 to your computer and use it in GitHub Desktop.
Save byjg/80eb3129bfe703658708b93c9ad3d261 to your computer and use it in GitHub Desktop.
Run Shell Script from Groovy
// 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