Package org.apache.jorphan.exec
Class SystemCommand
-
- All Implemented Interfaces:
public class SystemCommandUtility class for invoking native system applications
-
-
Field Summary
Fields Modifier and Type Field Description public final static intPOLL_INTERVALpublic Map<String, String>executionEnvironment
-
Constructor Summary
Constructors Constructor Description SystemCommand(File directory, Map<String, String> env)SystemCommand(File directory, long timeoutMillis, int pollInterval, Map<String, String> env, String stdin, String stdout, String stderr)SystemCommand(File directory, long timeoutMillis, int pollInterval, Map<String, String> env, InputStream stdin, OutputStream stdout, OutputStream stderr)
-
Method Summary
Modifier and Type Method Description Map<String, String>getExecutionEnvironment()Returns the executionEnvironment. intrun(List<String> arguments)Runs the command with given arguments and returns its return code. intrun(List<String> arguments1, List<String> arguments2)Pipe the output of one command into another StringgetOutResult()Returns Out/Err stream contents -
-
Constructor Detail
-
SystemCommand
SystemCommand(File directory, Map<String, String> env)
- Parameters:
directory- File working directory (may be null)env- Environment variables appended to environment (may be null)
-
SystemCommand
SystemCommand(File directory, long timeoutMillis, int pollInterval, Map<String, String> env, String stdin, String stdout, String stderr)
- Parameters:
directory- File working directory (may be null)timeoutMillis- timeout in MillisecondspollInterval- Value used to poll for Process execution endenv- Environment variables appended to environment (may be null)stdin- 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)
-
SystemCommand
SystemCommand(File directory, long timeoutMillis, int pollInterval, Map<String, String> env, InputStream stdin, OutputStream stdout, OutputStream stderr)
- Parameters:
directory- File working directory (may be null)timeoutMillis- timeout in MillisecondspollInterval- not used anymoreenv- Environment variables appended to environment (may be null)stdin- 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 Detail
-
getExecutionEnvironment
Map<String, String> getExecutionEnvironment()
Returns the executionEnvironment.
- Returns:
the executionEnvironment
-
run
int run(List<String> arguments)
Runs the command with given arguments and returns its return code.
- Parameters:
arguments- List of strings, not null- Returns:
return code
-
run
int run(List<String> arguments1, List<String> arguments2)
Pipe the output of one command into another
- Parameters:
arguments1- first command to runarguments2- second command to run- Returns:
exit status
-
getOutResult
String getOutResult()
Returns Out/Err stream contents
- Returns:
Out/Err stream contents
-
-
-
-