public class UnixCommandUtil
extends java.lang.Object
Constructor and Description |
---|
UnixCommandUtil() |
Modifier and Type | Method and Description |
---|---|
static boolean |
checkForOutput(java.lang.Process ps,
java.lang.String text)
Checks if the passed string is part of the output of the passed process.
|
static int |
getPID(java.lang.Process process)
Retrieves the pid of a unix process.
|
static boolean |
killAll(java.lang.String name)
Kills all processes with a given name.
|
static boolean |
killProcessConditional(java.lang.String pid,
java.lang.String name)
Checks if the process with pid passed contains the passed name when run
with ps.
|
static java.lang.Process |
launch(java.lang.String command,
java.lang.String[] params,
java.io.File path) |
static void |
launchAndConsume(java.lang.String command,
boolean print) |
static java.lang.Process |
launchAndConsume(java.lang.String command,
java.lang.String[] params,
java.io.File path,
boolean print) |
public static int getPID(java.lang.Process process) throws java.lang.NoSuchFieldException, java.lang.SecurityException, java.lang.IllegalArgumentException, java.lang.IllegalAccessException
process
- the process object to get the pid fromjava.lang.NoSuchFieldException
java.lang.SecurityException
java.lang.IllegalArgumentException
java.lang.IllegalAccessException
public static boolean killProcessConditional(java.lang.String pid, java.lang.String name)
pid
- the pid of the process to kill.name
- the name that has to appear when calling pspublic static boolean killAll(java.lang.String name)
name
- the name that has to appear when calling pspublic static boolean checkForOutput(java.lang.Process ps, java.lang.String text)
ps
- the process to get output fromtext
- the text that we expect to be part of the outputpublic static java.lang.Process launch(java.lang.String command, java.lang.String[] params, java.io.File path)
public static java.lang.Process launchAndConsume(java.lang.String command, java.lang.String[] params, java.io.File path, boolean print)
public static void launchAndConsume(java.lang.String command, boolean print)