ibis.util
Class RunProcess

java.lang.Object
  extended byibis.util.RunProcess

public final class RunProcess
extends java.lang.Object

Utility to run a process and read its output in a separate thread. Afterwards, the user can obtain the output or error output. To run a command, the sequence is:

     RunProcess p = new RunProcess("command ...");
     byte[] o = p.getStdout();
     byte[] e = p.getStderr();
     int status = p.getExitStatus();
 


Constructor Summary
RunProcess(java.lang.String command)
          Runs the command as specified.
RunProcess(java.lang.String[] command, java.lang.String[] env)
          Runs the command as specified.
RunProcess(java.lang.String[] command, java.lang.String[] env, java.io.File dir)
          Runs the command as specified.
 
Method Summary
 int getExitStatus()
          Returns the exit status of the process.
 byte[] getStderr()
          Returns the error output buffer of the process.
 byte[] getStdout()
          Returns the output buffer of the process.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RunProcess

public RunProcess(java.lang.String command)
Runs the command as specified. Blocks until the command is finished.

Parameters:
command - the specified command.

RunProcess

public RunProcess(java.lang.String[] command,
                  java.lang.String[] env)
Runs the command as specified. Blocks until the command is finished.

Parameters:
command - the specified command and arguments.
env - the environment.

RunProcess

public RunProcess(java.lang.String[] command,
                  java.lang.String[] env,
                  java.io.File dir)
Runs the command as specified. Blocks until the command is finished.

Parameters:
command - the specified command and arguments.
env - the environment.
dir - dir - the working directory of the command, or null for the working directory of this process.
Method Detail

getStdout

public byte[] getStdout()
Returns the output buffer of the process.

Returns:
the output buffer.

getStderr

public byte[] getStderr()
Returns the error output buffer of the process.

Returns:
the error output buffer.

getExitStatus

public int getExitStatus()
Returns the exit status of the process.

Returns:
the exit status.


The Ibis project