org.apache.hadoop.util
Class Shell.ShellCommandExecutor
java.lang.Object
org.apache.hadoop.util.Shell
org.apache.hadoop.util.Shell.ShellCommandExecutor
- Enclosing class:
- Shell
public static class Shell.ShellCommandExecutor
- extends Shell
A simple shell command executor.
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.
Method Summary |
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. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Shell.ShellCommandExecutor
public Shell.ShellCommandExecutor(java.lang.String[] execString)
Shell.ShellCommandExecutor
public Shell.ShellCommandExecutor(java.lang.String[] execString,
java.io.File dir)
Shell.ShellCommandExecutor
public Shell.ShellCommandExecutor(java.lang.String[] execString,
java.io.File dir,
java.util.Map<java.lang.String,java.lang.String> env)
execute
public void execute()
throws java.io.IOException
- Execute the shell command.
- Throws:
java.io.IOException
getExecString
protected java.lang.String[] getExecString()
- Description copied from class:
Shell
- return an array containing the command name & its parameters
- Specified by:
getExecString
in class Shell
parseExecResult
protected void parseExecResult(java.io.BufferedReader lines)
throws java.io.IOException
- Description copied from class:
Shell
- Parse the execution result
- Specified by:
parseExecResult
in class Shell
- Throws:
java.io.IOException
getOutput
public java.lang.String getOutput()
- Get the output of the shell command.
toString
public java.lang.String toString()
- Returns the commands of this instance.
Arguments with spaces in are presented with quotes round; other
arguments are presented raw
- Overrides:
toString
in class java.lang.Object
- Returns:
- a string representation of the object.
Copyright © 2009 The Apache Software Foundation