|
|
@@ -59,22 +59,23 @@ public class ScriptUtil {
|
|
59
|
59
|
// 标准输出:print (null if watchdog timeout)
|
|
60
|
60
|
// 错误输出:logging + 异常 (still exists if watchdog timeout)
|
|
61
|
61
|
// 标准输入
|
|
62
|
|
- FileOutputStream fileOutputStream = new FileOutputStream(logFile, true);
|
|
63
|
|
- PumpStreamHandler streamHandler = new PumpStreamHandler(fileOutputStream, fileOutputStream, null);
|
|
|
62
|
+ try (FileOutputStream fileOutputStream = new FileOutputStream(logFile, true)) {
|
|
|
63
|
+ PumpStreamHandler streamHandler = new PumpStreamHandler(fileOutputStream, fileOutputStream, null);
|
|
64
|
64
|
|
|
65
|
|
- // command
|
|
66
|
|
- CommandLine commandline = new CommandLine(command);
|
|
67
|
|
- commandline.addArgument(scriptFile);
|
|
68
|
|
- if (params!=null && params.length>0) {
|
|
69
|
|
- commandline.addArguments(params);
|
|
70
|
|
- }
|
|
|
65
|
+ // command
|
|
|
66
|
+ CommandLine commandline = new CommandLine(command);
|
|
|
67
|
+ commandline.addArgument(scriptFile);
|
|
|
68
|
+ if (params!=null && params.length>0) {
|
|
|
69
|
+ commandline.addArguments(params);
|
|
|
70
|
+ }
|
|
71
|
71
|
|
|
72
|
|
- // exec
|
|
73
|
|
- DefaultExecutor exec = new DefaultExecutor();
|
|
74
|
|
- exec.setExitValues(null);
|
|
75
|
|
- exec.setStreamHandler(streamHandler);
|
|
76
|
|
- int exitValue = exec.execute(commandline); // exit code: 0=success, 1=error
|
|
77
|
|
- return exitValue;
|
|
|
72
|
+ // exec
|
|
|
73
|
+ DefaultExecutor exec = new DefaultExecutor();
|
|
|
74
|
+ exec.setExitValues(null);
|
|
|
75
|
+ exec.setStreamHandler(streamHandler);
|
|
|
76
|
+ int exitValue = exec.execute(commandline); // exit code: 0=success, 1=error
|
|
|
77
|
+ return exitValue;
|
|
|
78
|
+ }
|
|
78
|
79
|
}
|
|
79
|
80
|
|
|
80
|
81
|
}
|