|
@@ -1,9 +1,7 @@
|
|
package com.gis.common.util;
|
|
package com.gis.common.util;
|
|
|
|
|
|
import cn.hutool.core.util.RuntimeUtil;
|
|
import cn.hutool.core.util.RuntimeUtil;
|
|
-import lombok.extern.log4j.Log4j2;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
|
|
|
import java.io.BufferedReader;
|
|
import java.io.BufferedReader;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
@@ -130,14 +128,15 @@ public class CmdUtils {
|
|
* 调用算法 xx.sh 脚本
|
|
* 调用算法 xx.sh 脚本
|
|
* @param command
|
|
* @param command
|
|
*/
|
|
*/
|
|
- public static void callShell_1(String command){
|
|
|
|
|
|
+ public static void callLineSh(String command, Integer lineSize){
|
|
log.info("cmd: {}", command);
|
|
log.info("cmd: {}", command);
|
|
try {
|
|
try {
|
|
String[] cmd = new String[]{"/bin/sh", "-c", command};
|
|
String[] cmd = new String[]{"/bin/sh", "-c", command};
|
|
Process process = Runtime.getRuntime().exec(cmd);
|
|
Process process = Runtime.getRuntime().exec(cmd);
|
|
|
|
+ CmdUtils.log.info("开始运行");
|
|
StreamGobblerLine errorGobbler = new StreamGobblerLine(process.getErrorStream(), "ERROR");
|
|
StreamGobblerLine errorGobbler = new StreamGobblerLine(process.getErrorStream(), "ERROR");
|
|
errorGobbler.start();
|
|
errorGobbler.start();
|
|
- StreamGobblerLine outGobbler = new StreamGobblerLine(process.getInputStream(), "STDOUT");
|
|
|
|
|
|
+ StreamGobblerLine outGobbler = new StreamGobblerLine(process.getInputStream(), "STDOUT", lineSize);
|
|
outGobbler.start();
|
|
outGobbler.start();
|
|
process.waitFor();
|
|
process.waitFor();
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
@@ -167,6 +166,6 @@ public class CmdUtils {
|
|
|
|
|
|
}
|
|
}
|
|
public static void callLineSh(String command){
|
|
public static void callLineSh(String command){
|
|
- callLine(command, null);
|
|
|
|
|
|
+ callLineSh(command, null);
|
|
}
|
|
}
|
|
}
|
|
}
|