summaryrefslogtreecommitdiffstats
path: root/framework/src/main/java
diff options
context:
space:
mode:
authorKanagaraj Manickam <mkr1481@gmail.com>2019-03-14 09:42:54 +0800
committerKanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>2019-03-14 09:45:52 +0800
commit19224b06b8f2cb1b8baeaf7e8bdfa77ab267dd45 (patch)
tree688d933d7f49040572ce31b4e477c9c18c2ec7ba /framework/src/main/java
parent0fa7bcf648503c5f112ec0dd0fc43b7de47311b2 (diff)
Fix process runner on unix
Issue-ID: CLI-129 Change-Id: Ic40c94b1059453858ff36e302beb44dbb4c1613b Signed-off-by: Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
Diffstat (limited to 'framework/src/main/java')
-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();
}