public static class Shell.ShellCommandExecutor extends Shell implements Shell.CommandExecutor
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.Shell.CommandExecutor, Shell.ExitCodeException, Shell.OSType, Shell.ShellCommandExecutorENV_HADOOP_HOME, ENV_NAME_REGEX, FREEBSD, inheritParentEnv, isSetsidAvailable, LINK_COMMAND, LINUX, LOG, MAC, osType, OTHER, PPC_64, READ_LINK_COMMAND, SET_GROUP_COMMAND, SET_OWNER_COMMAND, SET_PERMISSION_COMMAND, SOLARIS, SYSPROP_HADOOP_HOME_DIR, timeOutInterval, TOKEN_SEPARATOR_REGEX, USER_NAME_COMMAND, WINDOWS, WINDOWS_MAX_SHELL_LENGHT, WINDOWS_MAX_SHELL_LENGTH, WindowsProcessLaunchLock, WINUTILS| Constructor and Description |
|---|
Shell.ShellCommandExecutor(String[] execString) |
Shell.ShellCommandExecutor(String[] execString,
File dir) |
Shell.ShellCommandExecutor(String[] execString,
File dir,
Map<String,String> env) |
Shell.ShellCommandExecutor(String[] execString,
File dir,
Map<String,String> env,
long timeout) |
Shell.ShellCommandExecutor(String[] execString,
File dir,
Map<String,String> env,
long timeout,
boolean inheritParentEnv)
Create a new instance of the ShellCommandExecutor to execute a command.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
void |
execute()
Execute the shell command.
|
String[] |
getExecString()
return an array containing the command name and its parameters.
|
String |
getOutput()
Get the output of the shell command.
|
long |
getTimeoutInterval()
Returns the timeout value set for the executor's sub-commands.
|
protected void |
parseExecResult(BufferedReader lines)
Parse the execution result
|
String |
toString()
Returns the commands of this instance.
|
appendScriptExtension, appendScriptExtension, checkIsBashSupported, checkWindowsCommandLineLength, destroyAllShellProcesses, execCommand, execCommand, execCommand, getAllShells, getCheckProcessIsAliveCommand, getEnvironment, getEnvironmentVariableRegex, getExitCode, getGetPermissionCommand, getGroupsCommand, getGroupsForUserCommand, getGroupsIDForUserCommand, getHadoopHome, getMemlockLimit, getProcess, getQualifiedBin, getQualifiedBinPath, getReadlinkCommand, getRunScriptCommand, getSetOwnerCommand, getSetPermissionCommand, getSetPermissionCommand, getSignalKillCommand, getSymlinkCommand, getUsersForNetgroupCommand, getWaitingThread, getWinUtilsFile, getWinUtilsPath, hasWinutilsPath, isJava7OrAbove, isTimedOut, run, setEnvironment, setWorkingDirectoryclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetExitCodepublic Shell.ShellCommandExecutor(String[] execString)
public Shell.ShellCommandExecutor(String[] execString, File dir, Map<String,String> env)
public Shell.ShellCommandExecutor(String[] execString, File dir, Map<String,String> env, long timeout)
public Shell.ShellCommandExecutor(String[] execString, File dir, Map<String,String> env, long timeout, boolean inheritParentEnv)
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 timed-out.
If 0, the command will not be timed out.inheritParentEnv - Indicates if the process should inherit the env
vars from the parent process or not.public long getTimeoutInterval()
public void execute()
throws IOException
execute in interface Shell.CommandExecutorIOException - if the command fails, or if the command is
not well constructed.public String[] getExecString()
ShellgetExecString in class Shellprotected void parseExecResult(BufferedReader lines) throws IOException
ShellparseExecResult in class ShellIOExceptionpublic String getOutput()
getOutput in interface Shell.CommandExecutorpublic String toString()
public void close()
close in interface Shell.CommandExecutorCopyright © 2019 Apache Software Foundation. All Rights Reserved.