public static class Shell.ShellCommandExecutor extends Shell
ShellCommandExecutor
should 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.Shell.ExitCodeException, Shell.ShellCommandExecutor
SET_GROUP_COMMAND, SET_OWNER_COMMAND, SET_PERMISSION_COMMAND, timeOutInterval, ULIMIT_COMMAND, USER_NAME_COMMAND, WINDOWS
Constructor and Description |
---|
Shell.ShellCommandExecutor(java.lang.String[] execString) |
Shell.ShellCommandExecutor(java.lang.String[] execString,
java.io.File dir) |
Shell.ShellCommandExecutor(java.lang.String[] execString,
java.io.File dir,
java.util.Map<java.lang.String,java.lang.String> env) |
Shell.ShellCommandExecutor(java.lang.String[] execString,
java.io.File dir,
java.util.Map<java.lang.String,java.lang.String> env,
long timeout)
Create a new instance of the ShellCommandExecutor to execute a command.
|
Modifier and Type | Method and Description |
---|---|
void |
execute()
Execute the shell command.
|
protected java.lang.String[] |
getExecString()
return an array containing the command name & its parameters
|
java.lang.String |
getOutput()
Get the output of the shell command.
|
protected void |
parseExecResult(java.io.BufferedReader lines)
Parse the execution result
|
java.lang.String |
toString()
Returns the commands of this instance.
|
execCommand, execCommand, execCommand, getExitCode, getGET_PERMISSION_COMMAND, getGroupsCommand, getGroupsForUserCommand, getProcess, getUlimitMemoryCommand, isTimedOut, run, setEnvironment, setWorkingDirectory
public Shell.ShellCommandExecutor(java.lang.String[] execString)
public Shell.ShellCommandExecutor(java.lang.String[] execString, java.io.File dir)
public Shell.ShellCommandExecutor(java.lang.String[] execString, java.io.File dir, java.util.Map<java.lang.String,java.lang.String> env)
public Shell.ShellCommandExecutor(java.lang.String[] execString, java.io.File dir, java.util.Map<java.lang.String,java.lang.String> env, long timeout)
execString
- The command to execute with argumentsdir
- 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.public void execute() throws java.io.IOException
java.io.IOException
protected java.lang.String[] getExecString()
Shell
getExecString
in class Shell
protected void parseExecResult(java.io.BufferedReader lines) throws java.io.IOException
Shell
parseExecResult
in class Shell
java.io.IOException
public java.lang.String getOutput()
public java.lang.String toString()
toString
in class java.lang.Object
Copyright © 2018 The Apache Software Foundation