|
@@ -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: 子进程的输出就是主进程的输入)
|