ProcessRunner should use the cwd provided when calling Runtime.exec(...) 29/99829/1
authorJames Guistwite <jguistwite@iconectiv.com>
Thu, 19 Dec 2019 19:41:12 +0000 (14:41 -0500)
committerJames Guistwite <jguistwite@iconectiv.com>
Thu, 19 Dec 2019 19:56:49 +0000 (14:56 -0500)
Issue-ID: VNFSDK-501

Signed-off-by: James Guistwite <jguistwite@iconectiv.com>
Change-Id: If07360da610b8cc27102801f26502fe2df1004be

framework/src/main/java/org/onap/cli/fw/utils/ProcessRunner.java

index ff9d552..c0a910c 100644 (file)
@@ -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;