@NotThreadSafe public class ShellCommand extends Object
Constructor and Description |
---|
ShellCommand(String[] execString)
Creates a ShellCommand object with the command to exec.
|
Modifier and Type | Method and Description |
---|---|
String[] |
getCommand()
Gets the command.
|
String |
run()
Runs a command and returns its stdout on success.
|
CommandReturn |
runWithOutput()
Runs a command and returns its output and exit code in Object.
|
String |
toString()
Converts the command to string repr.
|
public ShellCommand(String[] execString)
execString
- shell commandpublic String run() throws IOException
IOException
- if the command returns a non-zero exit codepublic CommandReturn runWithOutput() throws IOException
CommandReturn
.
Stderr is redirected to stdout.CommandReturn
object representation of stdout, stderr and exit codeIOException
public String toString()
public String[] getCommand()
Copyright © 2023. All Rights Reserved.