|
@@ -29,7 +29,7 @@ public class CmdUtils {
|
|
|
|
|
|
|
|
|
|
|
|
- public static void callLineSh(String command){
|
|
|
+ public static void callLineSh(String command) throws Exception {
|
|
|
callLineSh(command, null);
|
|
|
|
|
|
}
|
|
@@ -68,21 +68,17 @@ public class CmdUtils {
|
|
|
* @param command 命令
|
|
|
* @param lineSize 日志输出行数 ,可以为null
|
|
|
*/
|
|
|
- public static void callLineSh(String command, Integer lineSize){
|
|
|
+ public static void callLineSh(String command, Integer lineSize) throws Exception {
|
|
|
log.info("cmd: " + command);
|
|
|
- try {
|
|
|
- String[] cmd = new String[]{"/bin/sh", "-c", command};
|
|
|
- Process process = Runtime.getRuntime().exec(cmd);
|
|
|
- log.info("开始运行");
|
|
|
- StreamGobblerLine errorGobbler = new StreamGobblerLine(process.getErrorStream(), "ERROR");
|
|
|
- errorGobbler.start();
|
|
|
- // 200行打印一次日志
|
|
|
- StreamGobblerLine outGobbler = new StreamGobblerLine(process.getInputStream(), "STDOUT", lineSize);
|
|
|
- outGobbler.start();
|
|
|
- process.waitFor();
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
+ String[] cmd = new String[]{"/bin/sh", "-c", command};
|
|
|
+ Process process = Runtime.getRuntime().exec(cmd);
|
|
|
+ log.info("开始运行");
|
|
|
+ StreamGobblerLine errorGobbler = new StreamGobblerLine(process.getErrorStream(), "ERROR");
|
|
|
+ errorGobbler.start();
|
|
|
+ // 200行打印一次日志
|
|
|
+ StreamGobblerLine outGobbler = new StreamGobblerLine(process.getInputStream(), "STDOUT", lineSize);
|
|
|
+ outGobbler.start();
|
|
|
+ process.waitFor();
|
|
|
}
|
|
|
|
|
|
/**
|