From 11561bf51f85514b30c152575368f14afd3947d0 Mon Sep 17 00:00:00 2001 From: wangshipeng Date: Thu, 20 Jan 2022 10:27:47 +0800 Subject: [PATCH] print command execute error info --- .../com/streamxhub/streamx/common/util/CommandUtils.scala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/streamx-common/src/main/scala/com/streamxhub/streamx/common/util/CommandUtils.scala b/streamx-common/src/main/scala/com/streamxhub/streamx/common/util/CommandUtils.scala index 3874bd319..e724fb0e4 100644 --- a/streamx-common/src/main/scala/com/streamxhub/streamx/common/util/CommandUtils.scala +++ b/streamx-common/src/main/scala/com/streamxhub/streamx/common/util/CommandUtils.scala @@ -20,6 +20,7 @@ package com.streamxhub.streamx.common.util import java.io._ import java.lang.{Iterable => JavaIter} +import java.util import java.util.Scanner import java.util.function.Consumer import scala.collection.JavaConversions._ @@ -65,7 +66,7 @@ object CommandUtils extends Logger { logDebug(s"Command execute:\n${commands.mkString("\n")} ") val process = Utils.isWindows match { case x if x => Runtime.getRuntime.exec("cmd /k ", null, null) - case _ => Runtime.getRuntime.exec("/bin/bash ", null, null) + case _ => new ProcessBuilder(util.Arrays.asList("/bin/bash")).redirectErrorStream(true).start } val out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(process.getOutputStream)), true) commands.foreach(out.println) -- Gitee