From be993dd46d6d0e093239cbb9234e586b8c3ae4ee Mon Sep 17 00:00:00 2001 From: James Guistwite Date: Thu, 19 Dec 2019 14:41:12 -0500 Subject: ProcessRunner should use the cwd provided when calling Runtime.exec(...) Issue-ID: VNFSDK-501 Signed-off-by: James Guistwite Change-Id: If07360da610b8cc27102801f26502fe2df1004be --- framework/src/main/java/org/onap/cli/fw/utils/ProcessRunner.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'framework') 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 ff9d5520..c0a910cf 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 @@ -92,13 +92,17 @@ public class ProcessRunner { public void run() throws InterruptedException, IOException { Process p = null; + File workingDirectory = null; + if (cwd != null) { + workingDirectory = new File(cwd); + } if (this.cmd.length == 1) { - p = Runtime.getRuntime().exec(this.shell + this.cmd[0], this.env, null); + p = Runtime.getRuntime().exec(this.shell + this.cmd[0], this.env, workingDirectory); } else { List list = new ArrayList(Arrays.asList(this.shell.split(" "))); list.addAll(Arrays.asList(this.cmd)); String []cmds = Arrays.copyOf(list.toArray(), list.size(), String[].class); - p = Runtime.getRuntime().exec(cmds, this.env, null); + p = Runtime.getRuntime().exec(cmds, this.env, workingDirectory); } boolean readOutput = false; -- cgit 1.2.3-korg