|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--com.denova.runtime.Exec
Provides methods to execute a command.
| Field Summary | |
static java.lang.String |
UnixCommandFilename
UnixCommandFilename is a temporary file called .tempjcmd. |
static java.lang.String |
WindowsCommandFilename
WindowsCommandFilename is a temporary file called _tempcmd.bat. |
| Constructor Summary | |
Exec()
|
|
| Method Summary | |
static int |
execCommand(java.lang.String programCommand)
Executes a program that uses stdin, stdout, and stderr. |
static int |
execCommand(java.lang.String[] commandArray)
Executes a program that uses stdin, stdout, and stderr. |
static java.util.List |
getCommandArgs(java.lang.String command)
Gets the command in an array list. |
static java.lang.String[] |
getCommandAsStringArray(java.lang.String command)
Gets the command array. |
static java.lang.String |
getCommandOutput(java.lang.String command)
Executes a command and returns the command's standard output as a String. |
static java.lang.String |
getCommandOutput(java.lang.String[] command)
Executes a command and returns the command's standard output as a String. |
static java.lang.String |
getWindowsCommand(java.lang.String command,
java.lang.String directory)
|
static boolean |
hasWhiteSpace(java.lang.String arg)
Returns true if the arg has one or more white space characters. |
static boolean |
isWhiteSpace(char c)
Returns true if the char is a white space character. |
static void |
launchCommand(java.lang.String command)
Executes a command; strongly recommend you use one of the other runCommand methods. |
static void |
launchCommand(java.lang.String command,
java.lang.String directory)
Executes a command from a directory. |
static void |
main(java.lang.String[] args)
Used to test running a command on a target system. |
static java.lang.String |
quoteArg(java.lang.String arg)
If the arg has one or more white space characters and doesn't already have quotes, add them. |
static void |
runCommand(java.lang.String command)
Executes a command; strongly recommend you use one of the other runCommand methods. |
static void |
runCommand(java.lang.String[] command)
Executes a command. |
static void |
runCommand(java.lang.String command,
java.io.File directory)
Executes a command from a directory. |
static void |
runCommand(java.lang.String command,
java.lang.String directory)
Executes a command from a directory. |
static void |
startAppWithoutWaiting(java.lang.String command)
Executes a command and does *not* wait for the process to start or finish. |
static java.lang.String |
unquoteArg(java.lang.String arg)
If the arg starts and ends with quotes, remove them |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final java.lang.String WindowsCommandFilename
public static final java.lang.String UnixCommandFilename
| Constructor Detail |
public Exec()
| Method Detail |
public static int execCommand(java.lang.String programCommand)
throws java.lang.Exception
The programCommand must start with the program name to run plus any command line arguments, if needed. The programCommand may not a built-in OS command, such as dir on a Windows.
programCommand - the full command line, including arguments to be executedjava.lang.Exception - any unexpected event
public static int execCommand(java.lang.String[] commandArray)
throws java.lang.Exception
The first argument must start with the program name, including the path, to run. The first argument may not a built-in OS command, such as dir on a Windows.
commandArray - the program name and arguments as separate itemsjava.lang.Exception - any unexpected event
public static void runCommand(java.lang.String command,
java.lang.String directory)
throws java.lang.Exception
If the command is issued on a Windows or Unix system, then a batch file or script is created which changes to directory, executes the command, moves back to the original directory, and erases the batch/script file.
command - the full command line, including arguments to be executeddirectory - the directory where the command will be launched
java.lang.Exception - any unexpected event
public static void runCommand(java.lang.String command,
java.io.File directory)
throws java.lang.Exception
If the command is issued on a Windows or Unix system, then a batch file or script is created which changes to directory, executes the command, moves back to the original directory, and erases the batch/script file.
command - full command line, including arguments to be executeddirectory - directory where the command will be launched
java.lang.Exception - any unexpected event
public static void runCommand(java.lang.String command)
throws java.lang.Exception
command - full command line, including arguments to be executedjava.lang.Exception - any unexpected event
public static void runCommand(java.lang.String[] command)
throws java.lang.Exception
command - the program name and arguments as separate itemsjava.lang.Exception - any unexpected event
public static java.lang.String getCommandOutput(java.lang.String command)
throws java.lang.Exception
command - full command line, including arguments to be executedjava.lang.Exception - any unexpected event
public static java.lang.String getCommandOutput(java.lang.String[] command)
throws java.lang.Exception
command - program name and arguments as separate itemsjava.lang.Exception - any unexpected event
public static void launchCommand(java.lang.String command,
java.lang.String directory)
throws java.lang.Exception
If the command is issued on a Windows or Unix system, then a batch file or script is created which changes to directory, executes the command, moves back to the original directory, and erases the batch/script file.
This command differs from runCommand because instead of calling p. waitFor() on Windows, it looks at the stdout for the EndOfStreamToken. This method handles a bug in some cmd.exe on WindowsNT. Important: The command that is being run through launchCommand must write to stdout or stderr for this method to work.
command - full command line, including arguments to be executeddirectory - directory where the command will be launched
java.lang.Exception - any unexpected event
public static void launchCommand(java.lang.String command)
throws java.lang.Exception
This command differs from runCommand because instead of calling p. waitFor() on Windows, it looks at the stdout for the EndOfStreamToken. This method handles a bug in some cmd.exe on WindowsNT. Important: The command that is being run through launchCommand must write to stdout or stderr for this method to work.
command - full command line, including arguments to be executedjava.lang.Exception - any unexpected event
public static void startAppWithoutWaiting(java.lang.String command)
throws java.lang.Exception
command - full command line, including arguments to be executedjava.lang.Exception - any unexpected event
public static java.lang.String[] getCommandAsStringArray(java.lang.String command)
throws java.lang.Exception
command -
java.lang.Exception - any unexpected event
public static java.util.List getCommandArgs(java.lang.String command)
throws java.lang.Exception
a.jar:"b c.jar":d.jar
Although newer JVMs don't require this quirk, there are a lot of
classpaths that use the old quoting. New JVMs still accept it, and
so we have to, too.
command -
java.lang.Exception - any unexpected event
public static java.lang.String getWindowsCommand(java.lang.String command,
java.lang.String directory)
public static void main(java.lang.String[] args)
args - The command line argumentspublic static java.lang.String quoteArg(java.lang.String arg)
arg - command line argument
public static java.lang.String unquoteArg(java.lang.String arg)
arg - command line argument
public static boolean hasWhiteSpace(java.lang.String arg)
arg - command line argument
public static boolean isWhiteSpace(char c)
c - character to check
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||