# Class SystemCommand

java.lang.Object
org.apache.jorphan.exec.SystemCommand

Direct Known Subclasses:
  `NativeCommand`

public class SystemCommand extends Object
Utility class for invoking native system applications

## Field Summary

Fields
Modifier and Type
Field
Description
`static final int`
`POLL_INTERVAL`

## Constructor Summary

Constructors
Constructor
Description
`SystemCommand(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 Type
Method
Description
`Map<String,String>`
`getExecutionEnvironment()`
`String`
`getOutResult()`
`int`
`run(List<String> arguments)`
`int`
`run(List<String> arguments1, List<String> arguments2)`
Pipe the output of one command into another

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### POLL_INTERVAL

public static final int POLL_INTERVAL

See Also:
  - Constant Field Values

## Constructor Details

### SystemCommand

public 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

public SystemCommand(File directory, long timeoutMillis, int pollInterval, Map<String,String> env, String stdin, String stdout, String stderr) throws IOException

Parameters:
  `directory` - File working directory (may be null)
  `timeoutMillis` - timeout in Milliseconds
  `pollInterval` - Value used to poll for Process execution end
  `env` - 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)
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:
  `directory` - File working directory (may be null)
  `timeoutMillis` - timeout in Milliseconds
  `pollInterval` - Value used to poll for Process execution end
  `env` - 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 Details

### run

public int run(List<String> arguments) throws InterruptedException, IOException

Parameters:
  `arguments` - List of strings, not null
Returns:
  return code
Throws:
  `InterruptedException` - when execution was interrupted
  `IOException` - when I/O error occurs while execution

### run

public int run(List<String> arguments1, List<String> arguments2) throws InterruptedException, IOException
Pipe the output of one command into another

Parameters:
  `arguments1` - first command to run
  `arguments2` - second command to run
Returns:
  exit status
Throws:
  `InterruptedException` - when execution gets interrupted
  `IOException` - when I/O error occurs while execution

### getOutResult

public String getOutResult()

Returns:
  Out/Err stream contents

### getExecutionEnvironment

public Map<String,String> getExecutionEnvironment()

Returns:
  the executionEnvironment