All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.sun.install.products.RunCmd

java.lang.Object
   |
   +----com.sun.install.products.RunCmd

public class RunCmd
extends Object
RunCmd is a class that can represent a running command and return its output and return values in a consistent fashion. It should be used anytime you would normally use a java.lang.System.exec() call.


Variable Index

 o ERRORS
Indicates we should collect the error output of the command (stderr in unix)
 o NORMAL
Indicates we should collect the normal output of the command (stdout in unix)

Constructor Index

 o RunCmd(String, boolean)
Create a command and indicate if it should collect output.
 o RunCmd(String, int)
Create a command and indicate if it should collect output, as well as which type of output to collect.
 o RunCmd(String, String, int)
Create a command and indicates which file (on the local filesystem) the output of the command should be appended to, and what types to collect.
 o RunCmd(String, String[], int)
Create a command and indicates which files (on the local filesystem) the output of the command should be appended to, and what types to collect.

Method Index

 o getAllOutput()
Gets both the output and the error output (stdout and stderr, respectively, on unix) from the command.
 o getErrorMessage()
Get the error message, if any
 o getErrors()
Gets the error output (stderr on unix) from the command.
 o getOutput()
Gets the output (stdout on unix) from the command.
 o getResult()
Gets the exit result code from the command.
 o getState()
Gets the state of the command.
 o readOutput(DataInputStream, DataInputStream)
Reads the output and the error output from the command, and stores it for later retrieval.

Variables

 o NORMAL
 public static final int NORMAL
Indicates we should collect the normal output of the command (stdout in unix)

 o ERRORS
 public static final int ERRORS
Indicates we should collect the error output of the command (stderr in unix)

Constructors

 o RunCmd
 public RunCmd(String command,
               boolean collectOutput)
Create a command and indicate if it should collect output. If you collect output, the output is stored in memory until the command is finished. If there is too much output, a java.lang.OutOfMemoryError will be thrown. In that case, you should use the RunCmd(String, int) variation with a type of NORMAL|ERRORS.

Parameters:
command - The command to execute
collectOutput - Whether this RunCmd should collect output.
 o RunCmd
 public RunCmd(String command,
               int which)
Create a command and indicate if it should collect output, as well as which type of output to collect.

Parameters:
cmd - The command to execute
collectOutput - Whether this RunCmd should collect output.
which - Indicates which type(s) of output to collect. Valid types are NORMAL, ERRORS, or a union of the possible types (i.e. NORMAL | ERRORS)
 o RunCmd
 public RunCmd(String command,
               String logOutputFile,
               int which)
Create a command and indicates which file (on the local filesystem) the output of the command should be appended to, and what types to collect.

Parameters:
cmd - The command to execute
logOutputFile - The file to output the output of the command to.
 o RunCmd
 public RunCmd(String command,
               String logOutputFiles[],
               int which)
Create a command and indicates which files (on the local filesystem) the output of the command should be appended to, and what types to collect.

Parameters:
cmd - The command to execute
logOutputFiles - The files to output the output of the command to.

Methods

 o getErrorMessage
 public String getErrorMessage()
Get the error message, if any

Returns:
The error message, if any from the command
 o getState
 public boolean getState()
Gets the state of the command. The state is false until the command has started.

Returns:
The state of the command.
 o getResult
 public int getResult()
Gets the exit result code from the command. On unix, normally a non-zero result indicates something did not run correctly.

Returns:
The result code from the command, or -1 if the command has not run.
 o getOutput
 public String getOutput()
Gets the output (stdout on unix) from the command.

Returns:
The output, if any, from the command.
 o getErrors
 public String getErrors()
Gets the error output (stderr on unix) from the command.

Returns:
The error output, if any, from the command.
 o getAllOutput
 public String getAllOutput()
Gets both the output and the error output (stdout and stderr, respectively, on unix) from the command.

Returns:
A combination of output and error output, if any, from the command
 o readOutput
 public void readOutput(DataInputStream in,
                        DataInputStream err)
Reads the output and the error output from the command, and stores it for later retrieval.

Parameters:
in - The stream representing the output from the program
err - The stream representing the error output from the program.

All Packages  Class Hierarchy  This Package  Previous  Next  Index