org.icenigrid.gridsam.core.plugin.shell
Class POSIXShell
java.lang.Object
org.icenigrid.gridsam.core.plugin.shell.AbstractShell
org.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.
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 java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
POSIXShell
public POSIXShell()
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 stringpProcessRoot
- the root directory where the process will be executed. Can be null if this parameter is not
usedpStdOut
- File to write the standard output topStdErr
- 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 stringpProcessRoot
- the root directory where the process will be executed. Can be null if this parameter is not
usedpStdOut
- File to write the standard output topStdErr
- File to write the standard error topStdIn
- 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 stringpProcessRoot
- the root directory where the process will be executed. Can be null if this parameter is not
usedpStdOut
- File to write the standard output topStdErr
- File to write the standard error topStdIn
- 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