|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
ObjectCommand
public class Command extends Object
The important method in this class is exec(String). It
executes its argument and pipes both stdout and stderr to System.out. Each
line in the piped output from stdout is prefixed with "OUT>" and the output
from stderr is prefixed with "ERR>"
Credit: Producer code modified (and augmented) from Michael Daconta's "Java Traps" column ("When Runtime.exec() won't"), found at http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
| Modifier and Type | Class and Description |
|---|---|
static class |
Command.KillBecauseTimeLimitExceed
|
static class |
Command.StreamGobbler
Helper class for Command. |
| Modifier and Type | Field and Description |
|---|---|
static String |
javaHeapSize
Argument to java command to set heap size |
static boolean |
no_execute
If true, commands will be printed, but not executed |
| Constructor and Description |
|---|
Command()
|
| Modifier and Type | Method and Description |
|---|---|
static int |
exec(String[] cmd)
Runs cmd, redirecting stdout and stderr to System.out. |
static int |
exec(String[] cmd,
PrintStream out,
PrintStream err)
Runs cmd, redirecting stdout and stderr to `out' and prefixing the output from stout with "OUT>" and the output from stderr with "ERR>". |
static int |
exec(String[] cmd,
PrintStream out,
PrintStream err,
String prompt)
|
static int |
exec(String[] cmd,
PrintStream out,
PrintStream err,
String prompt,
boolean gobbleChars)
Convenience method. |
static int |
exec(String[] cmd,
PrintStream out,
PrintStream err,
String prompt,
boolean gobbleChars,
File f)
|
static int |
exec(String[] cmd,
PrintStream out,
PrintStream err,
String prompt,
boolean gobbleChars,
int killAfterMillisPassed,
File workingDir)
|
static void |
runCommand(String[] command,
String prompt,
boolean verbose,
String nonVerboseMessage,
boolean gobbleChars)
|
static void |
runCommand(String[] command,
String prompt,
boolean verbose,
String nonVerboseMessage,
boolean okToFail,
boolean gobbleChars)
|
static void |
runCommandOKToFail(String[] command,
String prompt,
boolean verbose,
String nonVerboseMessage,
boolean gobbleChars)
|
| Methods inherited from class Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static boolean no_execute
public static String javaHeapSize
| Constructor Detail |
|---|
public Command()
| Method Detail |
|---|
public static void runCommand(String[] command,
String prompt,
boolean verbose,
String nonVerboseMessage,
boolean gobbleChars)
public static void runCommandOKToFail(String[] command,
String prompt,
boolean verbose,
String nonVerboseMessage,
boolean gobbleChars)
public static void runCommand(String[] command,
String prompt,
boolean verbose,
String nonVerboseMessage,
boolean okToFail,
boolean gobbleChars)
public static int exec(String[] cmd)
public static int exec(String[] cmd,
PrintStream out,
PrintStream err)
public static int exec(String[] cmd,
PrintStream out,
PrintStream err,
String prompt)
public static int exec(String[] cmd,
PrintStream out,
PrintStream err,
String prompt,
boolean gobbleChars)
public static int exec(String[] cmd,
PrintStream out,
PrintStream err,
String prompt,
boolean gobbleChars,
File f)
public static int exec(String[] cmd,
PrintStream out,
PrintStream err,
String prompt,
boolean gobbleChars,
int killAfterMillisPassed,
File workingDir)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||