|
|||||||||
| 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.StreamGobbler
Helper class for Command. |
| 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)
Runs cmd, redirecting stdout and stderr to System.out. |
static int |
exec(String[] cmd,
PrintStream out)
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,
String prompt)
|
static int |
exec(String[] cmd,
PrintStream out,
String prompt,
boolean gobbleChars)
|
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 |
| 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)
public static int exec(String[] cmd,
PrintStream out)
public static int exec(String[] cmd,
PrintStream out,
String prompt)
public static int exec(String[] cmd,
PrintStream out,
String prompt,
boolean gobbleChars)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||