Php 将2个输入流传递到symfony进程
我正在尝试使用symfony进程在两个远程文件之间执行差异。 从命令行执行命令是可行的,但是当我尝试使用php时,我的输出是空的Php 将2个输入流传递到symfony进程,php,symfony,Php,Symfony,我正在尝试使用symfony进程在两个远程文件之间执行差异。 从命令行执行命令是可行的,但是当我尝试使用php时,我的输出是空的 $process = new Process('diff <(ssh user@remote1 "cat /my/remote1/file.txt") <(ssh user@remote2 "cat /my/remote2/file.txt")'); $process->run(); $output = $process->getOutput(
$process = new Process('diff <(ssh user@remote1 "cat /my/remote1/file.txt") <(ssh user@remote2 "cat /my/remote2/file.txt")');
$process->run();
$output = $process->getOutput();
但结果仍然相同。您是否尝试过通过PHP获取文件内容,然后将其设置为输入?文档中没有提到bash命令可以用作输入,也不会执行。
另外:您使用什么将参数传递给
setInput
?我看到有一个类InputStream
,这可能会很神奇。我成功地分别获取了文件的内容,但我仍然无法将它们发送到diff进程。您是否可以使用mustRun()
方法而不是run()
来捕获任何失败?也许会有一些有用的东西?在文档中,您有一个调用的示例。您解决过这个问题吗?
$process = new Process('diff');
$process->setInput('(ssh user@remote1 "cat /my/remote1/file.txt")');
$process->setInput('(ssh user@remote2 "cat /my/remote2/file.txt")');
$process->run();
$output = $process->getOutput();