org.apache.hadoop.util
Class Shell.ShellCommandExecutor

java.lang.Object
  extended by org.apache.hadoop.util.Shell
      extended by org.apache.hadoop.util.Shell.ShellCommandExecutor
Enclosing class:
Shell

public static class Shell.ShellCommandExecutor
extends Shell

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 Summary
 
Nested classes/interfaces inherited from class org.apache.hadoop.util.Shell
Shell.ExitCodeException, Shell.ShellCommandExecutor
 
Field Summary
 
Fields inherited from class org.apache.hadoop.util.Shell
LOG, SET_GROUP_COMMAND, SET_OWNER_COMMAND, SET_PERMISSION_COMMAND, USER_NAME_COMMAND, WINDOWS
 
Constructor Summary
Shell.ShellCommandExecutor(String[] execString)
           
Shell.ShellCommandExecutor(String[] execString, File dir)
           
Shell.ShellCommandExecutor(String[] execString, File dir, Map<String,String> env)
           
 
Method Summary
 void execute()
          Execute the shell command.
protected  String[] getExecString()
          return an array containing the command name & its parameters
 String getOutput()
          Get the output of the shell command.
protected  void parseExecResult(BufferedReader lines)
          Parse the execution result
 
Methods inherited from class org.apache.hadoop.util.Shell
execCommand, getExitCode, getGET_PERMISSION_COMMAND, getGROUPS_COMMAND, getProcess, getUlimitMemoryCommand, run, setEnvironment, setWorkingDirectory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Shell.ShellCommandExecutor

public Shell.ShellCommandExecutor(String[] execString)

Shell.ShellCommandExecutor

public Shell.ShellCommandExecutor(String[] execString,
                                  File dir)

Shell.ShellCommandExecutor

public Shell.ShellCommandExecutor(String[] execString,
                                  File dir,
                                  Map<String,String> env)
Method Detail

execute

public void execute()
             throws IOException
Execute the shell command.

Throws:
IOException

getExecString

protected 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(BufferedReader lines)
                        throws IOException
Description copied from class: Shell
Parse the execution result

Specified by:
parseExecResult in class Shell
Throws:
IOException

getOutput

public String getOutput()
Get the output of the shell command.



Copyright © 2008 The Apache Software Foundation