|
@@ -10,7 +10,6 @@ public class CmdUtils {
|
|
|
|
|
|
|
|
|
/**
|
|
|
- * 调用算法 xx.sh 脚本
|
|
|
* @param command
|
|
|
*/
|
|
|
public static void callShell(String command){
|
|
@@ -27,5 +26,25 @@ public class CmdUtils {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 调用算法 xx.sh 脚本
|
|
|
+ * @param command
|
|
|
+ */
|
|
|
+ public static void callSh(String command){
|
|
|
+ log.info("cmd: {}", command);
|
|
|
+ try {
|
|
|
+ String[] cmd = new String[]{"/bin/sh", "-c", command};
|
|
|
+ Process process = Runtime.getRuntime().exec(cmd);
|
|
|
+ StreamGobbler errorGobbler = new StreamGobbler(process.getErrorStream(), "ERROR");
|
|
|
+ errorGobbler.start();
|
|
|
+ StreamGobbler outGobbler = new StreamGobbler(process.getInputStream(), "STDOUT");
|
|
|
+ outGobbler.start();
|
|
|
+ process.waitFor();
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
}
|