| java.lang.Object com.Ostermiller.util.ExecHelper
ExecHelper | final public class ExecHelper (Code) | | Convenience methods for executing non-Java processes.
More information about this class is available from ostermiller.org.
author: Stephen Ostermiller http://ostermiller.org/contact.pl?regarding=Java+Utilities since: ostermillerutils 1.06.00 |
Method Summary | |
public static ExecHelper | exec(String[] cmdarray) Executes the specified command and arguments in a separate process, and waits for the
process to finish.
Output from the process is expected to be text in the system's default character set.
No input is passed to the process on STDIN.
Parameters: cmdarray - array containing the command to call and its arguments. | public static ExecHelper | exec(String[] cmdarray, String[] envp) Executes the specified command and arguments in a separate process, and waits for the
process to finish.
Output from the process is expected to be text in the system's default character set.
No input is passed to the process on STDIN.
Parameters: cmdarray - array containing the command to call and its arguments. Parameters: envp - array of strings, each element of which has environment variable settings in format name=value. | public static ExecHelper | exec(String[] cmdarray, String[] envp, File dir) Executes the specified command and arguments in a separate process, and waits for the
process to finish.
Output from the process is expected to be text in the system's default character set.
No input is passed to the process on STDIN.
Parameters: cmdarray - array containing the command to call and its arguments. Parameters: envp - array of strings, each element of which has environment variable settings in format name=value. Parameters: dir - the working directory of the subprocess, or null if the subprocess should inherit the working directory of the current process. | public static ExecHelper | exec(String[] cmdarray, String charset) Executes the specified command and arguments in a separate process, and waits for the
process to finish.
No input is passed to the process on STDIN.
Parameters: cmdarray - array containing the command to call and its arguments. Parameters: charset - Output from the executed command is expected to be in this character set. | public static ExecHelper | exec(String[] cmdarray, String[] envp, String charset) Executes the specified command and arguments in a separate process, and waits for the
process to finish.
No input is passed to the process on STDIN.
Parameters: cmdarray - array containing the command to call and its arguments. Parameters: envp - array of strings, each element of which has environment variable settings in format name=value. Parameters: charset - Output from the executed command is expected to be in this character set. | public static ExecHelper | exec(String[] cmdarray, String[] envp, File dir, String charset) Executes the specified command and arguments in a separate process, and waits for the
process to finish.
No input is passed to the process on STDIN.
Parameters: cmdarray - array containing the command to call and its arguments. Parameters: envp - array of strings, each element of which has environment variable settings in format name=value. Parameters: dir - the working directory of the subprocess, or null if the subprocess should inherit the working directory of the current process. Parameters: charset - Output from the executed command is expected to be in this character set. | public static ExecHelper | execUsingShell(String command) Executes the specified command using a shell. | public static ExecHelper | execUsingShell(String command, String charset) Executes the specified command using a shell. | public String | getError() Get the error output of the job that ran. | public String | getOutput() Get the output of the job that ran. | public int | getStatus() Get the status of the job that ran. |
exec | public static ExecHelper exec(String[] cmdarray) throws IOException(Code) | | Executes the specified command and arguments in a separate process, and waits for the
process to finish.
Output from the process is expected to be text in the system's default character set.
No input is passed to the process on STDIN.
Parameters: cmdarray - array containing the command to call and its arguments. The results of the execution in an ExecHelper object. throws: SecurityException - if a security manager exists and its checkExec method doesn't allow creation of a subprocess. throws: IOException - - if an I/O error occurs throws: NullPointerException - - if cmdarray is null throws: IndexOutOfBoundsException - - if cmdarray is an empty array (has length 0). since: ostermillerutils 1.06.00 |
exec | public static ExecHelper exec(String[] cmdarray, String[] envp) throws IOException(Code) | | Executes the specified command and arguments in a separate process, and waits for the
process to finish.
Output from the process is expected to be text in the system's default character set.
No input is passed to the process on STDIN.
Parameters: cmdarray - array containing the command to call and its arguments. Parameters: envp - array of strings, each element of which has environment variable settings in format name=value. The results of the execution in an ExecHelper object. throws: SecurityException - if a security manager exists and its checkExec method doesn't allow creation of a subprocess. throws: IOException - - if an I/O error occurs throws: NullPointerException - - if cmdarray is null throws: IndexOutOfBoundsException - - if cmdarray is an empty array (has length 0). since: ostermillerutils 1.06.00 |
exec | public static ExecHelper exec(String[] cmdarray, String[] envp, File dir) throws IOException(Code) | | Executes the specified command and arguments in a separate process, and waits for the
process to finish.
Output from the process is expected to be text in the system's default character set.
No input is passed to the process on STDIN.
Parameters: cmdarray - array containing the command to call and its arguments. Parameters: envp - array of strings, each element of which has environment variable settings in format name=value. Parameters: dir - the working directory of the subprocess, or null if the subprocess should inherit the working directory of the current process. The results of the execution in an ExecHelper object. throws: SecurityException - if a security manager exists and its checkExec method doesn't allow creation of a subprocess. throws: IOException - - if an I/O error occurs throws: NullPointerException - - if cmdarray is null throws: IndexOutOfBoundsException - - if cmdarray is an empty array (has length 0). since: ostermillerutils 1.06.00 |
exec | public static ExecHelper exec(String[] cmdarray, String charset) throws IOException(Code) | | Executes the specified command and arguments in a separate process, and waits for the
process to finish.
No input is passed to the process on STDIN.
Parameters: cmdarray - array containing the command to call and its arguments. Parameters: charset - Output from the executed command is expected to be in this character set. The results of the execution in an ExecHelper object. throws: SecurityException - if a security manager exists and its checkExec method doesn't allow creation of a subprocess. throws: IOException - - if an I/O error occurs throws: NullPointerException - - if cmdarray is null throws: IndexOutOfBoundsException - - if cmdarray is an empty array (has length 0). since: ostermillerutils 1.06.00 |
exec | public static ExecHelper exec(String[] cmdarray, String[] envp, String charset) throws IOException(Code) | | Executes the specified command and arguments in a separate process, and waits for the
process to finish.
No input is passed to the process on STDIN.
Parameters: cmdarray - array containing the command to call and its arguments. Parameters: envp - array of strings, each element of which has environment variable settings in format name=value. Parameters: charset - Output from the executed command is expected to be in this character set. The results of the execution in an ExecHelper object. throws: SecurityException - if a security manager exists and its checkExec method doesn't allow creation of a subprocess. throws: IOException - - if an I/O error occurs throws: NullPointerException - - if cmdarray is null throws: IndexOutOfBoundsException - - if cmdarray is an empty array (has length 0). since: ostermillerutils 1.06.00 |
exec | public static ExecHelper exec(String[] cmdarray, String[] envp, File dir, String charset) throws IOException(Code) | | Executes the specified command and arguments in a separate process, and waits for the
process to finish.
No input is passed to the process on STDIN.
Parameters: cmdarray - array containing the command to call and its arguments. Parameters: envp - array of strings, each element of which has environment variable settings in format name=value. Parameters: dir - the working directory of the subprocess, or null if the subprocess should inherit the working directory of the current process. Parameters: charset - Output from the executed command is expected to be in this character set. The results of the execution in an ExecHelper object. throws: SecurityException - if a security manager exists and its checkExec method doesn't allow creation of a subprocess. throws: IOException - - if an I/O error occurs throws: NullPointerException - - if cmdarray is null throws: IndexOutOfBoundsException - - if cmdarray is an empty array (has length 0). since: ostermillerutils 1.06.00 |
execUsingShell | public static ExecHelper execUsingShell(String command) throws IOException(Code) | | Executes the specified command using a shell. On windows uses cmd.exe or command.exe.
On other platforms it uses /bin/sh.
A shell should be used to execute commands when features such as file redirection, pipes,
argument parsing are desired.
Output from the process is expected to be text in the system's default character set.
No input is passed to the process on STDIN.
Parameters: command - String containing a command to be parsed by the shell and executed. The results of the execution in an ExecHelper object. throws: SecurityException - if a security manager exists and its checkExec method doesn't allow creation of a subprocess. throws: IOException - - if an I/O error occurs throws: NullPointerException - - if command is null since: ostermillerutils 1.06.00 |
execUsingShell | public static ExecHelper execUsingShell(String command, String charset) throws IOException(Code) | | Executes the specified command using a shell. On windows uses cmd.exe or command.exe.
On other platforms it uses /bin/sh.
A shell should be used to execute commands when features such as file redirection, pipes,
argument parsing are desired.
No input is passed to the process on STDIN.
Parameters: command - String containing a command to be parsed by the shell and executed. Parameters: charset - Output from the executed command is expected to be in this character set. The results of the execution in an ExecHelper object. throws: SecurityException - if a security manager exists and its checkExec method doesn't allow creation of a subprocess. throws: IOException - - if an I/O error occurs throws: NullPointerException - - if command is null since: ostermillerutils 1.06.00 |
getError | public String getError()(Code) | | Get the error output of the job that ran.
Everything the executed process wrote to its standard error as a String. since: ostermillerutils 1.06.00 |
getOutput | public String getOutput()(Code) | | Get the output of the job that ran.
Everything the executed process wrote to its standard output as a String. since: ostermillerutils 1.06.00 |
getStatus | public int getStatus()(Code) | | Get the status of the job that ran.
exit status of the executed process, by convention, the value 0 indicates normal termination. since: ostermillerutils 1.06.00 |
|
|