I’m trying to execute multiple commands using Symfony Process Component but second command is not being processed. What am I doing wrong?
$process = new Process('sshpass -p password ssh user@host'); $process->run(); if (!$process->isSuccessful()) { throw new ProcessFailedException($process); } echo $process->getOutput(); $process1 = new Process("sudo reboot -f"); $process1->run(); if (!$process1->isSuccessful()) { throw new ProcessFailedException($process1); } echo $process1->getOutput();
Advertisement
Answer
Process are isolated, the second will not be executed inside the ssh session you open at the top of your code.
You must use only one process todo that.