Reputation: 157
I am trying to run two commands through exec() but it seems as if the commands are not correctly parsed.
I have the following code of line:
cmd = "scp -rp /mnt/backups/updateimage/images root@"+Arr.get(i)+":/usr/site/html ; ssh Arr.get(i)+" /usr/site/html/images/untar1.sh";
p = Runtime.getRuntime().exec(cmd);
Any idea how can I format my cmd string so that exec interprets it correctly ? Thanks
Upvotes: 1
Views: 691
Reputation: 269657
Execution of multiple, semi-colon delimited commands is feature provided by shells, but you are executing the scp
command.
If you want to use a shell, you should specify it as the command to be executed, with the actual commands as its arguments.
Upvotes: 2