ProcessRunner instead@Deprecated public class Shell extends Object
| Constructor and Description |
|---|
Shell()
Deprecated.
|
| Modifier and Type | Method and Description |
|---|---|
static ProcessStarter |
buildProcess(String command)
Deprecated.
Builds a process starter given a command.
|
static void |
dumpStacks()
Deprecated.
|
static String |
exec(String command)
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.
|
static String |
exec(String command,
String cs)
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.
|
void |
execWithPipe(String command)
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.
|
static String |
getAllThreadStacks()
Deprecated.
|
static OSPlatform.Platform |
getPlatform()
Deprecated.
use
OSPlatform.getPlatform() instead |
static boolean |
isLinux()
Deprecated.
use
OSPlatform.isLinux() instead |
static boolean |
isMac()
Deprecated.
use
OSPlatform.isMac() instead |
static boolean |
isSolaris()
Deprecated.
use
OSPlatform.isSolaris() instead |
static boolean |
isWindows()
Deprecated.
use
OSPlatform.isWindows() instead |
static String |
readLine(String prompt)
Deprecated.
Prints the given prompt and then reads a line from standard in.
|
static String |
readMaskedLine(String prompt)
Deprecated.
Prints the given prompt and then reads a line from standard in, but with the input
masked with asterisks
|
public static String exec(String command)
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 CommandFailedException is thrown.
Content sent to standard error by the command will be forwarded to standard error for this JVM. If you wish
to capture StdErr as well, use buildProcess(String) to create a ProcessStarter and call the ProcessStarter.withStdErrHandler(gw.util.ProcessStarter.OutputHandler)
method.
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 )
command - the command to executeCommandFailedException - if the process finishes with a non-zero return value
Note: On windows, CMD.EXE will be used to interpret "command" so that commands like "dir" work as expected. This can
occasionally cause problems due to limitations of CMD.EXE (e.g. a command string may be too long for it.) In these cases consider
using the buildProcess(String)
public static String exec(String command, String cs)
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 CommandFailedException is thrown.
Content sent to standard error by the command will be forwarded to standard error for this JVM. If you wish
to capture StdErr as well, use buildProcess(String) to create a ProcessStarter and call the ProcessStarter.withStdErrHandler(gw.util.ProcessStarter.OutputHandler)
method.
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 )
command - the command to executeCommandFailedException - if the process finishes with a non-zero return value
Note: On windows, CMD.EXE will be used to interpret "command" so that commands like "dir" work as expected. This can
occasionally cause problems due to limitations of CMD.EXE (e.g. a command string may be too long for it.) In these cases consider
using the buildProcess(String)
public void execWithPipe(String command)
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 CommandFailedException is 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.exec( "read \"are you there?\"" )
command - the command to executeCommandFailedException - if the process finishes with a non-zero return valuepublic static ProcessStarter buildProcess(String command)
command - the command to create a process starter for@Deprecated public static OSPlatform.Platform getPlatform()
OSPlatform.getPlatform() instead@Deprecated public static boolean isWindows()
OSPlatform.isWindows() instead@Deprecated public static boolean isMac()
OSPlatform.isMac() instead@Deprecated public static boolean isSolaris()
OSPlatform.isSolaris() instead@Deprecated public static boolean isLinux()
OSPlatform.isLinux() insteadpublic static String readLine(String prompt)
prompt - the prompt to show the userpublic static String readMaskedLine(String prompt)
prompt - the prompt to show the userpublic static String getAllThreadStacks()
public static void dumpStacks()
Copyright © 2018. All rights reserved.