lyhzzz 3 年之前
父節點
當前提交
eb1f29ab16
共有 1 個文件被更改,包括 2 次插入3 次删除
  1. 2 3
      src/main/java/com/fdkankan/fusion/common/util/ShellUtil.java

+ 2 - 3
src/main/java/com/fdkankan/fusion/common/util/ShellUtil.java

@@ -21,10 +21,9 @@ public class ShellUtil {
         long startTime = System.currentTimeMillis();
 
         try {
-            String[] commond = {"/bin/sh","-c",cmd};
             // 执行命令, 返回一个子进程对象(命令在子进程中执行)
-            log.info("执行cmd:{}",commond);
-            process = Runtime.getRuntime().exec(commond);
+            log.info("执行cmd:{}",cmd);
+            process = Runtime.getRuntime().exec(cmd);
             // 方法阻塞, 等待命令执行完成(成功会返回0)
             process.waitFor();
             // 获取命令执行结果, 有两个结果: 正常的输出 和 错误的输出(PS: 子进程的输出就是主进程的输入)