Package org.apache.storm.utils
Class ShellUtils.ShellCommandExecutor
java.lang.Object
org.apache.storm.utils.ShellUtils
org.apache.storm.utils.ShellUtils.ShellCommandExecutor
- Enclosing class:
- ShellUtils
A simple shell command executor.
 
ShellCommandExecutorshould be used in cases where the output
 of the command needs no explicit parsing and where the command, working directory and the environment remains unchanged. The output
 of the command is stored as-is and is expected to be small.- 
Nested Class SummaryNested classes/interfaces inherited from class org.apache.storm.utils.ShellUtilsShellUtils.ExitCodeException, ShellUtils.OSType, ShellUtils.ShellCommandExecutor
- 
Field SummaryFields inherited from class org.apache.storm.utils.ShellUtilsFREEBSD, LINUX, LOG, MAC, numShellExceptions, osType, OTHER, SOLARIS, timeOutInterval, TOKEN_SEPARATOR_REGEX, WINDOWS
- 
Constructor SummaryConstructorsConstructorDescriptionShellCommandExecutor(String[] execString) ShellCommandExecutor(String[] execString, File dir) Create a new instance of the ShellCommandExecutor to execute a command.
- 
Method SummaryModifier and TypeMethodDescriptionvoidexecute()Execute the shell command.String[]return an array containing the command name & its parameters.Get the output of the shell command.protected voidparseExecResult(BufferedReader lines) Parse the execution result.toString()Returns the commands of this instance.Methods inherited from class org.apache.storm.utils.ShellUtilsgetExitCode, getGroupsForUserCommand, getLogHandler, getProcess, isTimedOut, run, setEnvironment, setWorkingDirectory
- 
Constructor Details- 
ShellCommandExecutor
- 
ShellCommandExecutor
- 
ShellCommandExecutor
- 
ShellCommandExecutorCreate a new instance of the ShellCommandExecutor to execute a command.- Parameters:
- execString- The command to execute with arguments
- dir- If not-null, specifies the directory which should be set as the current working directory for the command. If null, the current working directory is not modified.
- env- If not-null, environment of the command will include the key-value pairs specified in the map. If null, the current environment is not modified.
- timeout- Specifies the time in milliseconds, after which the command will be killed and the status marked as timedout. If 0, the command will not be timed out.
 
 
- 
- 
Method Details- 
executeExecute the shell command.- Throws:
- IOException
 
- 
getExecStringDescription copied from class:ShellUtilsreturn an array containing the command name & its parameters.- Specified by:
- getExecStringin class- ShellUtils
 
- 
parseExecResultDescription copied from class:ShellUtilsParse the execution result.- Specified by:
- parseExecResultin class- ShellUtils
- Throws:
- IOException
 
- 
getOutputGet the output of the shell command.
- 
toStringReturns the commands of this instance. Arguments with spaces in are presented with quotes round; other arguments are presented raw
 
-