proper.io
Class Shell

java.lang.Object
  extended by proper.io.Shell

public class Shell
extends java.lang.Object

This class is a wrapper around a Process-Instance and makes it easy to get the last command and its error or execption or output.

Version:
$Revision: 1.2 $
Author:
FracPete

Constructor Summary
Shell()
          initializes
Shell(java.lang.String cmd)
          executes the given command
Shell(java.lang.String cmd, boolean wait)
          executes the given command
 
Method Summary
 int execute(java.lang.String cmd)
          executes the given command
 int execute(java.lang.String cmd, boolean wait)
          executes the given command
 java.lang.String lastCommand()
          returns the last executed command
 java.lang.Exception lastException()
          returns the Exception (if any exists) from the last execute
 java.lang.String lastStderr()
          returns the output on error out from the last execute
 java.lang.String lastStdout()
          returns the output on standard out of the last execute
static void main(java.lang.String[] args)
          for testing purposes only
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Shell

public Shell()
initializes


Shell

public Shell(java.lang.String cmd)
executes the given command

Parameters:
cmd - the command to execute

Shell

public Shell(java.lang.String cmd,
             boolean wait)
executes the given command

Parameters:
cmd - the command to execute
wait - whether to wait or not
Method Detail

execute

public int execute(java.lang.String cmd)
executes the given command

Parameters:
cmd - the command to execute
Returns:
the exit value of the command

execute

public int execute(java.lang.String cmd,
                   boolean wait)
executes the given command

Parameters:
cmd - the command to execute
wait - wait for process to finish
Returns:
the exit value of the command

lastStdout

public java.lang.String lastStdout()
returns the output on standard out of the last execute

Returns:
the last output if any exists

lastStderr

public java.lang.String lastStderr()
returns the output on error out from the last execute

Returns:
the last error if any exists

lastCommand

public java.lang.String lastCommand()
returns the last executed command

Returns:
the last executed command

lastException

public java.lang.Exception lastException()
returns the Exception (if any exists) from the last execute

Returns:
the last exception if existing

main

public static void main(java.lang.String[] args)
for testing purposes only