我正在尝试在 Symfony 5.1 中运行 Linux 进程,如下所述: https: //symfony.com/doc/current/components/process.html
use Symfony\Component\Process\Process;
(...)
$command = 'echo hello';
$process = new Process([$command]);
$process->start();
foreach ($process as $type => $data) {
if ($process::OUT === $type) {
echo "\nRead from stdout: ".$data;
} else { // $process::ERR === $type
echo "\nRead from stderr: ".$data;
}
}
无论我的命令行是什么,我都会得到以下输出:
Read from stderr: sh: 1: exec: echo hello: not found
紫衣仙女
料青山看我应如是