randoop.experiments
Class Command

Object
  extended by Command

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


Nested Class Summary
Modifier and Type Class and Description
static class Command.KillBecauseTimeLimitExceed
           
static class Command.StreamGobbler
          Helper class for Command.
 
Field Summary
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 Summary
Constructor and Description
Command()
           
 
Method Summary
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

no_execute

public static boolean no_execute
If true, commands will be printed, but not executed


javaHeapSize

public static String javaHeapSize
Argument to java command to set heap size

Constructor Detail

Command

public Command()
Method Detail

runCommand

public static void runCommand(String[] command,
                              String prompt,
                              boolean verbose,
                              String nonVerboseMessage,
                              boolean gobbleChars)

runCommandOKToFail

public static void runCommandOKToFail(String[] command,
                                      String prompt,
                                      boolean verbose,
                                      String nonVerboseMessage,
                                      boolean gobbleChars)

runCommand

public static void runCommand(String[] command,
                              String prompt,
                              boolean verbose,
                              String nonVerboseMessage,
                              boolean okToFail,
                              boolean gobbleChars)

exec

public static int exec(String[] cmd)
Runs cmd, redirecting stdout and stderr to System.out.


exec

public 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>". Returns whatever exit number is returned by the subprocess invoking the command.


exec

public static int exec(String[] cmd,
                       PrintStream out,
                       PrintStream err,
                       String prompt)

exec

public static int exec(String[] cmd,
                       PrintStream out,
                       PrintStream err,
                       String prompt,
                       boolean gobbleChars)
Convenience method. Equivalent to exec(cmd, out, err, prompt, gobbleChars, null).


exec

public static int exec(String[] cmd,
                       PrintStream out,
                       PrintStream err,
                       String prompt,
                       boolean gobbleChars,
                       File f)

exec

public static int exec(String[] cmd,
                       PrintStream out,
                       PrintStream err,
                       String prompt,
                       boolean gobbleChars,
                       int killAfterMillisPassed,
                       File workingDir)