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.
-
ERRORS
- Indicates we should collect the error output of the command (stderr in unix)
-
NORMAL
- Indicates we should collect the normal output of the command (stdout in unix)
-
RunCmd(String, boolean)
- Create a command and indicate if it should collect output.
-
RunCmd(String, int)
- Create a command and indicate if it should collect output, as well as which type of output to collect.
-
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.
-
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.
-
getAllOutput()
- Gets both the output and the error output (stdout and stderr,
respectively, on unix) from the command.
-
getErrorMessage()
- Get the error message, if any
-
getErrors()
- Gets the error output (stderr on unix) from the command.
-
getOutput()
- Gets the output (stdout on unix) from the command.
-
getResult()
- Gets the exit result code from the command.
-
getState()
- Gets the state of the command.
-
readOutput(DataInputStream, DataInputStream)
- Reads the output and the error output from the command,
and stores it for later retrieval.
NORMAL
public static final int NORMAL
- Indicates we should collect the normal output of the command (stdout in unix)
ERRORS
public static final int ERRORS
- Indicates we should collect the error output of the command (stderr in unix)
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.
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)
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.
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.
getErrorMessage
public String getErrorMessage()
- Get the error message, if any
- Returns:
- The error message, if any from the command
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.
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.
getOutput
public String getOutput()
- Gets the output (stdout on unix) from the command.
- Returns:
- The output, if any, from the command.
getErrors
public String getErrors()
- Gets the error output (stderr on unix) from the command.
- Returns:
- The error output, if any, from the command.
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
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