Echo exec 不工作 tesseract

Echo exec not working tesseract

我正在研究将 tesseract 与 PHP 结合使用,这是我第一次使用 exec.

/usr/local/bin/tesseract /images/hello.png stdout 通过 SSH 完美运行,但是当我通过 PHP;

尝试 运行 时没有任何反应
echo exec('/usr/local/bin/tesseract images/hello.png result');

但如果我尝试;

echo exec('/usr/local/bin/tesseract images/hello.png result 2>&1');

然后页面写着Tesseract Open Source OCR Engine v3.03 with Leptonica所以我觉得我必须关闭

有什么想法吗?

使用以下方法使其正常工作

exec('/usr/local/bin/tesseract /images/hello.png stdout', $msg);
print_r($msg);

http://php.net/manual/en/function.exec.php

Return 值

命令结果的最后一行。如果你需要执行一个命令,并让命令中的所有数据直接传回而不受任何干扰,请使用 passthru() 函数。

要获取执行命令的输出,请务必设置并使用输出参数。