Package com.logicaldoc.util.exec
Class Exec
java.lang.Object
com.logicaldoc.util.exec.Exec
Utility class used to execute system commands
- Since:
- 6.3
- Author:
- Marco Meschieri - LogicalDOC
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionintExecute the command by using the Runtime.execintintintExecute the command by using the Runtime.getRuntime().exec()intExecutes the command by using the Runtime.getRuntime().exec()execGetOutput(String commandLine, List<String> env, File dir) Execute the command by using the Runtime.getRuntime().exec()Executes the command by using the Runtime.getRuntime().exec()intExecutes the command by using the process builder.intExecutes the command by using the process builder.booleanChecks if you are running on WindowsvoidsetErrPrefix(String errPrefix) voidsetOutPrefix(String outPrefix) 
- 
Constructor Details- 
Execpublic Exec()
 
- 
- 
Method Details- 
setErrPrefix
- 
setOutPrefix
- 
isWindowspublic boolean isWindows()Checks if you are running on Windows- Returns:
- true if the execution platform is Windows
 
- 
execPBpublic int execPB(List<String> commandLine, Map<String, String> environment, File directory, int timeout) throws IOExceptionExecutes the command by using the process builder.- Parameters:
- commandLine- The command line to process. The path of the command must be listed in the allowed-commands.txt
- environment- The environemnt variables
- directory- The folder where the command will be executed
- timeout- The timeout in seconds
- Returns:
- the return value
- Throws:
- IOException- raised in case of errors during execution
 
- 
execPBExecutes the command by using the process builder.- Parameters:
- commandLine- The command line to process. The path of the command must be listed in the allowed-commands.txt
- directory- The folder where the command will be executed
- timeout- The timeout in seconds
- Returns:
- the return value
- Throws:
- IOException- raised in case of errors during execution
 
- 
execExecute the command by using the Runtime.getRuntime().exec()- Parameters:
- commandLine- the list of elements in the command line. The path of the command must be listed in the allowed-commands.txt
- Returns:
- the command execution return value
- Throws:
- IOException- raised in case of errors during execution
 
- 
execpublic int exec(List<String> commandLine, List<String> env, File dir, int timeout) throws IOException Executes the command by using the Runtime.getRuntime().exec()- Parameters:
- commandLine- the list of elements in the command line. The path of the command must be listed in the allowed-commands.txt
- env- the environment variables
- dir- the current folder
- timeout- maximum execution time expressed in seconds
- Returns:
- the return code of the command
- Throws:
- IOException- raised in case of errors during execution
 
- 
execGetOutputpublic String execGetOutput(List<String> commandLine, List<String> env, File dir, int timeout) throws IOException Executes the command by using the Runtime.getRuntime().exec()- Parameters:
- commandLine- the list of elements in the command line. The path of the command must be listed in the allowed-commands.txt
- env- the environment variables
- dir- the current folder
- timeout- maximum execution time expressed in seconds
- Returns:
- The output of the command
- Throws:
- IOException- raised in case of errors during execution
 
- 
execGetOutputExecute the command by using the Runtime.getRuntime().exec()- Parameters:
- commandLine- the command line string. The path of the command must be listed in the allowed-commands.txt
- env- the execution environment
- dir- the current folder
- Returns:
- The output of the command
- Throws:
- IOException- If the execution caused an error
 
- 
execpublic int exec(String commandLine, List<String> env, File dir, StringBuilder buffer, int timeout) throws IOException - Throws:
- IOException
 
- 
execpublic int exec(String commandLine, List<String> env, File dir, Writer outputWriter, int timeout) throws IOException - Throws:
- IOException
 
- 
execExecute the command by using the Runtime.exec- Parameters:
- commandLine- the command line. The path of the command must be listed in the allowed-commands.txt
- env- the environment variables
- dir- the current execution directory
- timeout- maximum execution time expressed in seconds
- Returns:
- the command return value
- Throws:
- IOException- raised if the command produced an error
 
 
-