org.icenigrid.gridsam.core.plugin.shell
Class POSIXShell

java.lang.Object
  extended byorg.icenigrid.gridsam.core.plugin.shell.AbstractShell
      extended byorg.icenigrid.gridsam.core.plugin.shell.POSIXShell
All Implemented Interfaces:
Shell
Direct Known Subclasses:
LocalShell, SSHShell

public abstract class POSIXShell
extends AbstractShell

Class representing a POSIX compliant shell. Client can optionally change the location of the POSIX shell path. The default is /bin/sh. All subclass must common POSIX compliant command string.


Nested Class Summary
 
Nested classes inherited from class org.icenigrid.gridsam.core.plugin.shell.AbstractShell
AbstractShell.PipeRunnable
 
Field Summary
 
Fields inherited from class org.icenigrid.gridsam.core.plugin.shell.AbstractShell
STDERR, STDOUT
 
Constructor Summary
POSIXShell()
           
 
Method Summary
 int executeCommand(String pCommandString, File pProcessRoot, Properties pEnv, File pStdOut, File pStdErr, File pStdIn)
          execute a command synchronously.
 Process executeCommandAsynchronously(String pCommandString, File pProcessRoot, Properties pEnv, File pStdOut, File pStdErr)
          execute a system process asynchronously.
 Process executeCommandAsynchronously(String pCommandString, File pProcessRoot, Properties pEnv, File pStdOut, File pStdErr, File pStdIn)
          execute a command synchronously.
 String getPosixShellPath()
          get the path to the posix shell executable
 void setPosixShellPath(String pPath)
          set the path to the posix shell executable
 
Methods inherited from class org.icenigrid.gridsam.core.plugin.shell.AbstractShell
executeCommand, executeCommand, executeCommand, executeCommandAsynchronously, pipeStream
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.icenigrid.gridsam.core.plugin.shell.Shell
close, executeCommandAsynchronously, getFileSystem
 

Constructor Detail

POSIXShell

public POSIXShell()
Method Detail

setPosixShellPath

public void setPosixShellPath(String pPath)
set the path to the posix shell executable

Parameters:
pPath - the file path

getPosixShellPath

public String getPosixShellPath()
get the path to the posix shell executable

Returns:
String the file path

executeCommandAsynchronously

public Process executeCommandAsynchronously(String pCommandString,
                                            File pProcessRoot,
                                            Properties pEnv,
                                            File pStdOut,
                                            File pStdErr)
                                     throws IOException
execute a system process asynchronously. The method returns once the process starts executing.

Parameters:
pCommandString - the command string
pProcessRoot - the root directory where the process will be executed. Can be null if this parameter is not used
pStdOut - File to write the standard output to
pStdErr - File to write the standard error to
Returns:
Process the process object for the caller to manage the lifetime of this process
Throws:
IOException - if the command cannot be executed

executeCommand

public int executeCommand(String pCommandString,
                          File pProcessRoot,
                          Properties pEnv,
                          File pStdOut,
                          File pStdErr,
                          File pStdIn)
                   throws InterruptedException,
                          IOException
execute a command synchronously. The method returns when the process exits. Client can provide a file name for both the standard output and error stream. The file name is logical to the underlying shell. If the shell is a remote shell, the file name is relative to the remote file system, not the local system the shell is executing.

Parameters:
pCommandString - the command string
pProcessRoot - the root directory where the process will be executed. Can be null if this parameter is not used
pStdOut - File to write the standard output to
pStdErr - File to write the standard error to
pStdIn - File to read as standard input
Returns:
int the exit value of the system command
Throws:
InterruptedException - if the command is interrupted
IOException - if the command cannot be executed

executeCommandAsynchronously

public Process executeCommandAsynchronously(String pCommandString,
                                            File pProcessRoot,
                                            Properties pEnv,
                                            File pStdOut,
                                            File pStdErr,
                                            File pStdIn)
                                     throws InterruptedException,
                                            IOException
execute a command synchronously. The method returns when the process exits. Client can provide a file name for both the standard output and error stream. The file name is logical to the underlying shell. If the shell is a remote shell, the file name is relative to the remote file system, not the local system the shell is executing.

Parameters:
pCommandString - the command string
pProcessRoot - the root directory where the process will be executed. Can be null if this parameter is not used
pStdOut - File to write the standard output to
pStdErr - File to write the standard error to
pStdIn - File to read as standard input
Returns:
Process The process handle
Throws:
InterruptedException - if the command is interrupted
IOException - if the command cannot be executed