Package org.apache.jorphan.exec
Class SystemCommand
java.lang.Object
org.apache.jorphan.exec.SystemCommand
Utility class for invoking native system applications
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Deprecated.does not make sense anymore. -
Constructor Summary
ConstructorDescriptionSystemCommand
(File directory, long timeoutMillis, int pollInterval, Map<String, String> env, InputStream stdin, OutputStream stdout, OutputStream stderr) SystemCommand
(File directory, long timeoutMillis, int pollInterval, Map<String, String> env, String stdin, String stdout, String stderr) SystemCommand
(File directory, Map<String, String> env) -
Method Summary
Modifier and TypeMethodDescriptionReturns the executionEnvironment.Returns Out/Err stream contentsint
Runs the command with given arguments and returns its return code.int
Pipe the output of one command into another
-
Field Details
-
POLL_INTERVAL
Deprecated.does not make sense anymore. Superseded byObject.wait(long)
- See Also:
-
-
Constructor Details
-
SystemCommand
- Parameters:
env
- Environment variables appended to environment (may be null)directory
- File working directory (may be null)
-
SystemCommand
public SystemCommand(File directory, long timeoutMillis, int pollInterval, Map<String, String> env, String stdin, String stdout, String stderr) throws IOException- Parameters:
env
- Environment variables appended to environment (may be null)directory
- File working directory (may be null)timeoutMillis
- timeout in MillisecondspollInterval
- Value used to poll for Process execution endstdin
- File name that will contain data to be input to process (may be null)stdout
- File name that will contain out stream (may be null)stderr
- File name that will contain err stream (may be null)- Throws:
IOException
- if the input file is not found or output cannot be written
-
SystemCommand
public SystemCommand(File directory, long timeoutMillis, int pollInterval, Map<String, String> env, InputStream stdin, OutputStream stdout, OutputStream stderr) - Parameters:
env
- Environment variables appended to environment (may be null)directory
- File working directory (may be null)timeoutMillis
- timeout in MillisecondspollInterval
- not used anymorestdin
- File name that will contain data to be input to process (may be null)stdout
- File name that will contain out stream (may be null)stderr
- File name that will contain err stream (may be null)
-
-
Method Details
-
run
Runs the command with given arguments and returns its return code.- Parameters:
arguments
- List of strings, not null- Returns:
- return code
- Throws:
InterruptedException
- when execution was interruptedIOException
- when I/O error occurs while executionTimeoutException
- when timeout is reached while execution
-
run
public int run(List<String> arguments1, List<String> arguments2) throws InterruptedException, IOException, TimeoutException Pipe the output of one command into another- Parameters:
arguments1
- first command to runarguments2
- second command to run- Returns:
- exit status
- Throws:
InterruptedException
- when execution gets interruptedTimeoutException
- when timeout is reached while executionIOException
- when I/O error occurs while execution
-
getOutResult
Returns Out/Err stream contents- Returns:
- Out/Err stream contents
-
getExecutionEnvironment
Returns the executionEnvironment.- Returns:
- the executionEnvironment
-