aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsubhash kumar singh <subhash.kumar.singh@huawei.com>2019-03-14 02:03:49 +0000
committerGerrit Code Review <gerrit@onap.org>2019-03-14 02:03:49 +0000
commitdf809f402e23b935e438c29c232f3e246a81f184 (patch)
treea8a083360c41b56da47031487128a6a8b33e0279
parent65d9d65c6e3bf9f4f5590a3ba3d9234b63c04596 (diff)
parent19224b06b8f2cb1b8baeaf7e8bdfa77ab267dd45 (diff)
Merge "Fix process runner on unix"
-rw-r--r--framework/src/main/java/org/onap/cli/fw/utils/ProcessRunner.java10
1 files changed, 9 insertions, 1 deletions
diff --git a/framework/src/main/java/org/onap/cli/fw/utils/ProcessRunner.java b/framework/src/main/java/org/onap/cli/fw/utils/ProcessRunner.java
index 9b896230..eb335837 100644
--- a/framework/src/main/java/org/onap/cli/fw/utils/ProcessRunner.java
+++ b/framework/src/main/java/org/onap/cli/fw/utils/ProcessRunner.java
@@ -28,10 +28,14 @@ import java.util.Map;
import java.util.concurrent.TimeUnit;
import org.apache.commons.io.IOUtils;
+import org.onap.cli.fw.cmd.OnapCommand;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class ProcessRunner {
+ private static Logger log = LoggerFactory.getLogger(ProcessRunner.class);
public static final String WIN_SHELL = "cmd.exe /c ";
- public static final String UNIX_SHELL = "sh -c ";
+ public static final String UNIX_SHELL = "";
private String []cmd = null;
private String shell = System.getProperty("os.name").toLowerCase().startsWith("windows") ? WIN_SHELL : UNIX_SHELL;
private String cwd = System.getProperty("user.home");
@@ -80,6 +84,7 @@ public class ProcessRunner {
Process p = null;
final StringWriter writerOutput = new StringWriter();
final StringWriter writerError = new StringWriter();
+
if (this.cmd.length == 1) {
p = Runtime.getRuntime().exec(this.shell + this.cmd[0], this.env, null);
} else {
@@ -113,6 +118,9 @@ public class ProcessRunner {
this.exitCode = p.exitValue();
this.output = writerOutput.toString();
this.error = writerError.toString();
+ log.debug("CMD: " + Arrays.asList(this.cmd).toString() + "\nWORKING_DIR: " + this.cwd + "\nENV: " +
+ ((this.env == null) ? this.env : Arrays.asList(this.env).toString()) +
+ "\nOUTPUT: " + this.output + "\nERROR: " + this.error + "\nEXIT_CODE: " + this.exitCode);
p.destroy();
}