|
|
@@ -65,8 +65,11 @@ public class ScriptUtil {
|
|
|
* @param command
|
|
|
* @param scriptFile
|
|
|
* @param logFile
|
|
|
+ * @param params
|
|
|
+ * @return
|
|
|
+ * @throws IOException
|
|
|
*/
|
|
|
- public static void execToFile(String command, String scriptFile, String logFile) throws IOException {
|
|
|
+ public static int execToFile(String command, String scriptFile, String logFile, String... params) throws IOException {
|
|
|
// 标准输出:print (null if watchdog timeout)
|
|
|
// 错误输出:logging + 异常 (still exists if watchdog timeout)
|
|
|
// 标准输入
|
|
|
@@ -76,12 +79,16 @@ public class ScriptUtil {
|
|
|
// command
|
|
|
CommandLine commandline = new CommandLine(command);
|
|
|
commandline.addArgument(scriptFile);
|
|
|
+ if (params!=null && params.length>0) {
|
|
|
+ commandline.addArguments(params);
|
|
|
+ }
|
|
|
|
|
|
// exec
|
|
|
DefaultExecutor exec = new DefaultExecutor();
|
|
|
exec.setExitValues(null);
|
|
|
exec.setStreamHandler(streamHandler);
|
|
|
- int exitValue = exec.execute(commandline);
|
|
|
+ int exitValue = exec.execute(commandline); // exit code: 0=success, 1/-1=fail
|
|
|
+ return exitValue;
|
|
|
}
|
|
|
|
|
|
}
|