public class Execute
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static int |
INVALID
Invalid exit code.
|
| Constructor and Description |
|---|
Execute()
Creates a new execute object using
PumpStreamHandler for stream handling. |
Execute(ExecuteStreamHandler streamHandler)
Creates a new execute object.
|
Execute(ExecuteStreamHandler streamHandler,
ExecuteWatchdog watchdog)
Creates a new execute object.
|
| Modifier and Type | Method and Description |
|---|---|
int |
execute()
Runs a process defined by the command line and returns its exit status.
|
static int |
execute(java.util.Vector<java.lang.String> envVars,
java.lang.String cmd,
java.io.File baseDir) |
static int |
execute(java.util.Vector<java.lang.String> envVars,
java.util.Vector<java.lang.String> cmd,
java.io.File baseDir) |
static int |
execute(java.util.Vector<java.lang.String> envVars,
java.util.Vector<java.lang.String> cmd,
java.io.File baseDir,
int timeToWait)
Wrapper for common execution patterns
|
java.lang.String[] |
getCommandline()
Returns the commandline used to create a subprocess.
|
java.lang.String |
getCommandLineString() |
java.lang.String[] |
getEnvironment()
Returns the environment used to create a subprocess.
|
int |
getExitValue()
query the exit value of the process.
|
static java.util.Vector<java.lang.String> |
getProcEnvironment()
Find the list of environment variables for this process.
|
void |
kill() |
void |
setCommandline(java.lang.String[] commandline)
Sets the commandline of the subprocess to launch.
|
void |
setEnvironment(java.lang.String[] env)
Sets the environment variables for the subprocess to launch.
|
protected void |
setExitValue(int value) |
void |
setNewenvironment(boolean newenv)
Set whether to propagate the default environment or not.
|
void |
setWorkingDirectory(java.io.File wd)
Sets the working directory of the process to execute.
|
protected void |
waitFor(java.lang.Process process) |
public static final int INVALID
public Execute()
PumpStreamHandler for stream handling.public Execute(ExecuteStreamHandler streamHandler)
streamHandler - the stream handler used to handle the input and output streams of the subprocess.public Execute(ExecuteStreamHandler streamHandler, ExecuteWatchdog watchdog)
streamHandler - the stream handler used to handle the input and output streams of the subprocess.watchdog - a watchdog for the subprocess or null to to disable a timeout for the subprocess.public static java.util.Vector<java.lang.String> getProcEnvironment()
public java.lang.String[] getCommandline()
public java.lang.String getCommandLineString()
public void setCommandline(java.lang.String[] commandline)
commandline - the commandline of the subprocess to launchpublic void setNewenvironment(boolean newenv)
newenv - whether to propagate the process environment.public java.lang.String[] getEnvironment()
public void setEnvironment(java.lang.String[] env)
env - array of Strings, each element of which has an environment variable settings in format
key=valuepublic void setWorkingDirectory(java.io.File wd)
This is emulated using the antRun scripts unless the OS is Windows NT in which case a cmd.exe is spawned, or MRJ and setting user.dir works, or JDK 1.3 and there is official support in java.lang.Runtime.
wd - the working directory of the process.public int execute()
throws java.lang.Exception
INVALIDjava.lang.Exception - if launching of the subprocess failedpublic void kill()
protected void waitFor(java.lang.Process process)
protected void setExitValue(int value)
public int getExitValue()
public static int execute(java.util.Vector<java.lang.String> envVars,
java.lang.String cmd,
java.io.File baseDir)
public static int execute(java.util.Vector<java.lang.String> envVars,
java.util.Vector<java.lang.String> cmd,
java.io.File baseDir)
public static int execute(java.util.Vector<java.lang.String> envVars,
java.util.Vector<java.lang.String> cmd,
java.io.File baseDir,
int timeToWait)
envVars - Environment variables to execute with (optional)cmd - a vector of the commands to executebaseDir - the base directory to run from (optional)timeToWait - milliseconds to wait for completion