Class ProcessStarter
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classDeprecated.private static classDeprecated.static classDeprecated.static interfaceDeprecated.static interfaceDeprecated.private static classDeprecated.private static classDeprecated. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate StringDeprecated.private booleanDeprecated.private booleanDeprecated.private final ProcessBuilderDeprecated.private final StringDeprecated.private WriterDeprecated.private WriterDeprecated.private booleanDeprecated.private static final StringDeprecated.static final ProcessStarter.OutputHandlerDeprecated. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionDeprecated.If called, this ProcessStarter will not throw an exception if the underlying process exits with a non-zero return codeexec()Deprecated.Executes the given command as if it had been executed from the command line of the host OS (cmd.exe on windows, /bin/sh on *nix) and returns all content sent to standard out as a string.voidDeprecated.Executes the given command as if it had been executed from the command line of the host OS (cmd.exe on windows, /bin/sh on *nix) and pipes all data sent to this processes stdout, stderr, and stdin.private voidDeprecated.Deprecated.Returns this process' working directory.Deprecated.Returns a modifiable string map view of this process' environment.private voidhandleCommand(Writer stdOut, Writer stdErr) Deprecated.Deprecated.If called, this ProcessStarter will include the StdErr output in the return string of this process.private static StringDeprecated.parseCommandLine(String str) Deprecated.voidDeprecated.Executes the given command as if it had been executed from the command line of the host OS (cmd.exe on windows, /bin/sh on *nix) and calls the provided handler with the newly created process.voidsetDirectory(File directory) Deprecated.Sets this process' working directory.start()Deprecated.Starts a new process using the attributes of this process starter.private ProcessDeprecated.withCharset(String cs) Deprecated.withCMD()Deprecated.The process built up will use CMD if this is a windows platform.withStdErrHandler(ProcessStarter.OutputHandler stdErrHandler) Deprecated.withStdOutHandler(ProcessStarter.OutputHandler stdOutHandler) Deprecated.
-
Field Details
-
IGNORE
Deprecated. -
CONSOLE_NEWLINE
Deprecated. -
_pb
Deprecated. -
_withCMD
private boolean _withCMDDeprecated. -
_inludeStdErrInOutput
private boolean _inludeStdErrInOutputDeprecated. -
_dontThrowOnNonZeroReturn
private boolean _dontThrowOnNonZeroReturnDeprecated. -
_rawCmd
Deprecated. -
_stdOut
Deprecated. -
_stdErr
Deprecated. -
_charset
Deprecated.
-
-
Constructor Details
-
ProcessStarter
Deprecated.
-
-
Method Details
-
parseCommandLine
Deprecated. -
exec
Deprecated.Executes the given command as if it had been executed from the command line of the host OS (cmd.exe on windows, /bin/sh on *nix) and returns all content sent to standard out as a string. If the command finishes with a non zero return value, a
CommandFailedExceptionis thrown.Content sent to standard error by the command will be forwarded to standard error for this JVM.
This method blocks on the execution of the command.
Example Usages:
var currentDir = Shell.exec( "dir" ) // windows var currentDir = Shell.exec( "ls" ) // *nix Shell.exec( "rm -rf " + directoryToNuke )
- Returns:
- the content of standard out
- Throws:
CommandFailedException- if the process finishes with a non-zero return value
-
flush
Deprecated. -
execWithPipe
public void execWithPipe()Deprecated.Executes the given command as if it had been executed from the command line of the host OS (cmd.exe on windows, /bin/sh on *nix) and pipes all data sent to this processes stdout, stderr, and stdin. If the command finishes with a non zero return value, a
CommandFailedExceptionis thrown.Stdout and Stderr from the sub-process will be piped to the current process' stdout and stderr. Any input in this processes stdin will be piped to the sub-process' stdin
Content sent to standard error by the command will be forwarded to standard error for this JVM.
This method blocks on the execution of the command.
Example Usages:
Shell.execWithPipe( "read \"are you there?\"" )
- Throws:
CommandFailedException- if the process finishes with a non-zero return value
-
startImpl
Deprecated.- Throws:
IOException
-
processWithHandler
Deprecated.Executes the given command as if it had been executed from the command line of the host OS (cmd.exe on windows, /bin/sh on *nix) and calls the provided handler with the newly created process.
NOTE: In gosu, you should take advantage of the block-to-interface coercion provided and pass blocks in as the handler. See the examples below.
- Parameters:
handler- the process handler for this process.
-
start
Deprecated.Starts a new process using the attributes of this process starter.The new process will invoke the command and arguments given by
ProcessBuilder.command(), in a working directory as given bygetDirectory(), with a process environment as given bygetEnvironment().This method calls directly to
ProcessBuilder.start.- Returns:
- A new
Processobject for managing the subprocess - Throws:
NullPointerException- If an element of the command list is nullIndexOutOfBoundsException- If the command is an empty list (has size0)SecurityException- If a security manager exists and itscheckExecmethod doesn't allow creation of the subprocessIOException- If an I/O error occurs- See Also:
-
getEnvironment
Deprecated.Returns a modifiable string map view of this process' environment. Whenever a process starter is created, the environment is initialized to a copy of the current process environment (seeSystem.getenv()). Subprocesses subsequently started by this object will use this map as their environment.The returned object may be modified using ordinary
Mapoperations. These modifications will be visible to subprocesses. TwoProcessStarterinstances always contain independent process environments, so changes to the returned map will never be reflected in any otherProcessStarterinstance or the values returned bySystem.getenv. There are many system-dependant restrictions placed on the returned map. SeeProcessBuilderfor more information- Returns:
- This process environment
- Throws:
SecurityException- If a security manager exists and itscheckPermissionmethod doesn't allow access to the process environment- See Also:
-
getDirectory
Deprecated.Returns this process' working directory. Subprocesses subsequently started by this object will use this as their working directory. The returned value may benull-- this means to use the working directory of the current Java process, usually the directory named by the system propertyuser.dir, as the working directory of the child process.- Returns:
- This process's working directory
-
setDirectory
Deprecated.Sets this process' working directory. Subprocesses subsequently started by this object will use this as their working directory. The returned value may benull-- this means to use the working directory of the current Java process, usually the directory named by the system propertyuser.dir, as the working directory of the child process.- Parameters:
directory- This process' working directory
-
handleCommand
Deprecated. -
indent
Deprecated. -
withCharset
Deprecated. -
withCMD
Deprecated.The process built up will use CMD if this is a windows platform. This is necessary because on windows certain basic commands such as "dir" are not programs, but rather are built into CMD. Thanks, Microsoft. -
includeStdErrInOutput
Deprecated.If called, this ProcessStarter will include the StdErr output in the return string of this process. Note that this has no effect ifwithStdErrHandler(OutputHandler)is called.- Returns:
- this object for chaining
-
doNotThrowOnNonZeroReturnVal
Deprecated.If called, this ProcessStarter will not throw an exception if the underlying process exits with a non-zero return code- Returns:
- this object for chaining
-
withStdErrHandler
Deprecated.- Parameters:
stdErrHandler- handler that will be called with every line of output to stderr- Returns:
- this object for chaining
-
withStdOutHandler
Deprecated.- Parameters:
stdOutHandler- handler that will be called with every line of output to stdout- Returns:
- this object for chaining
-
ProcessRunnerinstead