public abstract class CommandLineUtils extends Object
Constructor and Description |
---|
CommandLineUtils() |
Modifier and Type | Method and Description |
---|---|
static int |
executeCommandLine(org.codehaus.plexus.util.cli.Commandline cl,
InputStream systemIn,
org.codehaus.plexus.util.cli.StreamConsumer systemOut,
org.codehaus.plexus.util.cli.StreamConsumer systemErr) |
static int |
executeCommandLine(org.codehaus.plexus.util.cli.Commandline cl,
InputStream systemIn,
org.codehaus.plexus.util.cli.StreamConsumer systemOut,
org.codehaus.plexus.util.cli.StreamConsumer systemErr,
int timeoutInSeconds) |
static int |
executeCommandLine(org.codehaus.plexus.util.cli.Commandline cl,
org.codehaus.plexus.util.cli.StreamConsumer systemOut,
org.codehaus.plexus.util.cli.StreamConsumer systemErr) |
static int |
executeCommandLine(org.codehaus.plexus.util.cli.Commandline cl,
org.codehaus.plexus.util.cli.StreamConsumer systemOut,
org.codehaus.plexus.util.cli.StreamConsumer systemErr,
int timeoutInSeconds) |
static org.codehaus.plexus.util.cli.CommandLineCallable |
executeCommandLineAsCallable(org.codehaus.plexus.util.cli.Commandline cl,
InputStream systemIn,
org.codehaus.plexus.util.cli.StreamConsumer systemOut,
org.codehaus.plexus.util.cli.StreamConsumer systemErr,
int timeoutInSeconds)
Immediately forks a process, returns a callable that will block until process is complete.
|
static Properties |
getSystemEnvVars()
Gets the shell environment variables for this process.
|
static Properties |
getSystemEnvVars(boolean caseSensitive)
Return the shell environment variables.
|
static boolean |
isAlive(Process p) |
static String |
quote(String argument)
Deprecated.
Use
StringUtils.quoteAndEscape(String, char, char[], char[], char, boolean) , StringUtils.quoteAndEscape(String, char, char[], char, boolean) , or
StringUtils.quoteAndEscape(String, char) instead. |
static String |
quote(String argument,
boolean wrapExistingQuotes)
Deprecated.
Use
StringUtils.quoteAndEscape(String, char, char[], char[], char, boolean) , StringUtils.quoteAndEscape(String, char, char[], char, boolean) , or
StringUtils.quoteAndEscape(String, char) instead. |
static String |
quote(String argument,
boolean escapeSingleQuotes,
boolean escapeDoubleQuotes,
boolean wrapExistingQuotes)
Deprecated.
Use
StringUtils.quoteAndEscape(String, char, char[], char[], char, boolean) , StringUtils.quoteAndEscape(String, char, char[], char, boolean) , or
StringUtils.quoteAndEscape(String, char) instead. |
static String |
toString(String[] line) |
static String[] |
translateCommandline(String toProcess) |
static void |
waitForAllPumpers(StreamFeeder inputFeeder,
StreamPumper outputPumper,
StreamPumper errorPumper) |
public CommandLineUtils()
public static int executeCommandLine(org.codehaus.plexus.util.cli.Commandline cl, org.codehaus.plexus.util.cli.StreamConsumer systemOut, org.codehaus.plexus.util.cli.StreamConsumer systemErr) throws org.codehaus.plexus.util.cli.CommandLineException
org.codehaus.plexus.util.cli.CommandLineException
public static int executeCommandLine(org.codehaus.plexus.util.cli.Commandline cl, org.codehaus.plexus.util.cli.StreamConsumer systemOut, org.codehaus.plexus.util.cli.StreamConsumer systemErr, int timeoutInSeconds) throws org.codehaus.plexus.util.cli.CommandLineException
org.codehaus.plexus.util.cli.CommandLineException
public static int executeCommandLine(org.codehaus.plexus.util.cli.Commandline cl, InputStream systemIn, org.codehaus.plexus.util.cli.StreamConsumer systemOut, org.codehaus.plexus.util.cli.StreamConsumer systemErr) throws org.codehaus.plexus.util.cli.CommandLineException
org.codehaus.plexus.util.cli.CommandLineException
public static int executeCommandLine(org.codehaus.plexus.util.cli.Commandline cl, InputStream systemIn, org.codehaus.plexus.util.cli.StreamConsumer systemOut, org.codehaus.plexus.util.cli.StreamConsumer systemErr, int timeoutInSeconds) throws org.codehaus.plexus.util.cli.CommandLineException
cl
- The command line to executesystemIn
- The input to read from, must be thread safesystemOut
- A consumer that receives output, must be thread safesystemErr
- A consumer that receives system error stream output, must be thread safetimeoutInSeconds
- Positive integer to specify timeout, zero and negative integers for no timeout.Process.exitValue()
CommandLineException
- or CommandLineTimeOutException if time out occurspublic static org.codehaus.plexus.util.cli.CommandLineCallable executeCommandLineAsCallable(org.codehaus.plexus.util.cli.Commandline cl, InputStream systemIn, org.codehaus.plexus.util.cli.StreamConsumer systemOut, org.codehaus.plexus.util.cli.StreamConsumer systemErr, int timeoutInSeconds) throws org.codehaus.plexus.util.cli.CommandLineException
cl
- The command line to executesystemIn
- The input to read from, must be thread safesystemOut
- A consumer that receives output, must be thread safesystemErr
- A consumer that receives system error stream output, must be thread safetimeoutInSeconds
- Positive integer to specify timeout, zero and negative integers for no timeout.Process.exitValue()
. "call" must be called on this to be sure the forked process has
terminated, no guarantees is made about any internal state before the completion of the call statementCommandLineException
- or CommandLineTimeOutException if time out occurspublic static void waitForAllPumpers(StreamFeeder inputFeeder, StreamPumper outputPumper, StreamPumper errorPumper) throws InterruptedException
InterruptedException
public static Properties getSystemEnvVars() throws IOException
getSystemEnvVars().get("path")
and getSystemEnvVars().get("PATH")
will in general return different values. However, on platforms with
case-insensitive environment variables like Windows, all variable names will be normalized to upper case.null
.IOException
- If the environment variables could not be queried from the shell.System.getenv() API, new in JDK 5.0, to get the same result since 2.0.2 System#getenv() will be used if available in the current running jvm.
public static Properties getSystemEnvVars(boolean caseSensitive) throws IOException
caseSensitive == true
, then envar keys will all be upper-case.caseSensitive
- Whether environment variable keys should be treated case-sensitively.IOException
- .System.getenv() API, new in JDK 5.0, to get the same result since 2.0.2 System#getenv() will be used if available in the current running jvm.
public static String[] translateCommandline(String toProcess) throws Exception
Exception
@Deprecated public static String quote(String argument) throws org.codehaus.plexus.util.cli.CommandLineException
StringUtils.quoteAndEscape(String, char, char[], char[], char, boolean)
, StringUtils.quoteAndEscape(String, char, char[], char, boolean)
, or
StringUtils.quoteAndEscape(String, char)
instead.Put quotes around the given String if necessary.
If the argument doesn't include spaces or quotes, return it as is. If it contains double quotes, use single quotes - else surround the argument by double quotes.
CommandLineException
- if the argument contains both, single and double quotes.@Deprecated public static String quote(String argument, boolean wrapExistingQuotes) throws org.codehaus.plexus.util.cli.CommandLineException
StringUtils.quoteAndEscape(String, char, char[], char[], char, boolean)
, StringUtils.quoteAndEscape(String, char, char[], char, boolean)
, or
StringUtils.quoteAndEscape(String, char)
instead.Put quotes around the given String if necessary.
If the argument doesn't include spaces or quotes, return it as is. If it contains double quotes, use single quotes - else surround the argument by double quotes.
CommandLineException
- if the argument contains both, single and double quotes.@Deprecated public static String quote(String argument, boolean escapeSingleQuotes, boolean escapeDoubleQuotes, boolean wrapExistingQuotes) throws org.codehaus.plexus.util.cli.CommandLineException
StringUtils.quoteAndEscape(String, char, char[], char[], char, boolean)
, StringUtils.quoteAndEscape(String, char, char[], char, boolean)
, or
StringUtils.quoteAndEscape(String, char)
instead.org.codehaus.plexus.util.cli.CommandLineException
Copyright © 2010–2014 The Kuali Foundation. All rights reserved.