|
@@ -65,8 +65,11 @@ public class ScriptUtil {
|
65
|
65
|
* @param command
|
66
|
66
|
* @param scriptFile
|
67
|
67
|
* @param logFile
|
|
68
|
+ * @param params
|
|
69
|
+ * @return
|
|
70
|
+ * @throws IOException
|
68
|
71
|
*/
|
69
|
|
- public static void execToFile(String command, String scriptFile, String logFile) throws IOException {
|
|
72
|
+ public static int execToFile(String command, String scriptFile, String logFile, String... params) throws IOException {
|
70
|
73
|
// 标准输出:print (null if watchdog timeout)
|
71
|
74
|
// 错误输出:logging + 异常 (still exists if watchdog timeout)
|
72
|
75
|
// 标准输入
|
|
@@ -76,12 +79,16 @@ public class ScriptUtil {
|
76
|
79
|
// command
|
77
|
80
|
CommandLine commandline = new CommandLine(command);
|
78
|
81
|
commandline.addArgument(scriptFile);
|
|
82
|
+ if (params!=null && params.length>0) {
|
|
83
|
+ commandline.addArguments(params);
|
|
84
|
+ }
|
79
|
85
|
|
80
|
86
|
// exec
|
81
|
87
|
DefaultExecutor exec = new DefaultExecutor();
|
82
|
88
|
exec.setExitValues(null);
|
83
|
89
|
exec.setStreamHandler(streamHandler);
|
84
|
|
- int exitValue = exec.execute(commandline);
|
|
90
|
+ int exitValue = exec.execute(commandline); // exit code: 0=success, 1/-1=fail
|
|
91
|
+ return exitValue;
|
85
|
92
|
}
|
86
|
93
|
|
87
|
94
|
}
|