Tool for running shell commands, just a thin wrapper around the java runtime exec calls. Note that there are already at least two standard ways of doing this with Groovy APIs, which may or may not be more convenient depending on your use case.
| Modifiers | Name | Description |
|---|---|---|
static class |
ShellTool.Result |
Simple bean for the result of executing a shell command. |
| Type | Name and description |
|---|---|
groovy.lang.Closure |
stderrLineHandler |
groovy.lang.Closure |
stdoutLineHandler |
java.io.File |
workingDirectory |
| Constructor and description |
|---|
ShellTool
()Constructor. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
java.util.Map<java.lang.String, java.lang.String> |
getEnv()Get environment variables for the command. |
|
groovy.lang.Closure |
getStderrLineHandler()Get closure for handling stderr lines. |
|
groovy.lang.Closure |
getStdoutLineHandler()Get closure for handling stdout lines. |
|
java.io.File |
getWorkingDirectory()Get working directory for command. |
|
ShellTool.Result |
run(java.lang.String command)Run the given shell command and return the result. |
|
ShellTool.Result |
run(java.util.List<java.lang.String> cmdList)Run the given shell command and return the result. |
|
ShellTool |
setEnvironment(java.util.Map<java.lang.String, java.lang.String> env)Set environment variables for the command. |
|
ShellTool |
setStderrLineHandler(groovy.lang.Closure handler)Set a closure that will be called to handle each line of stderr. |
|
ShellTool |
setStdoutLineHandler(groovy.lang.Closure handler)Set a closure that will be called to handle each line of stdout. |
|
ShellTool |
setWorkingDirectory(java.io.File workingDirectory)Set working directory for the command. |
| Methods inherited from class | Name |
|---|---|
class java.lang.Object |
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Get environment variables for the command.
Get closure for handling stderr lines.
Get closure for handling stdout lines.
Get working directory for command.
Run the given shell command and return the result. If an exception occurs, the return code of the result is set to -1, stderr of the result is set to the stack trace of the exception and stdout of the result is set to an empty string.
command - command to runRun the given shell command and return the result. If an exception occurs, the return code of the result is set to -1, stderr of the result is set to the stack trace of the exception and stdout of the result is set to an empty string.
cmdList - list containing the command and its argumentsSet environment variables for the command. Key is variable name, value is variable value. If not set or set to null, inherit from parent process.
Set a closure that will be called to handle each line of stderr. If not set or set to null, do nothing.
Set a closure that will be called to handle each line of stdout. If not set or set to null, do nothing.
Set working directory for the command. If not set or set to null, inherit from parent process.
Groovy Documentation