【问题标题】:PHP shell exec commandPHP shell 执行命令
【发布时间】:2016-07-28 07:44:09
【问题描述】:

我正在使用一个 Windows 应用程序 tesseract,长话短说,这是一个通过命令运行的 OCR 应用程序。

安装应用程序后,我使用命令进行测试并使用此行正常工作:

tesseract text.png out

它实际上获取图像并输出到文本文件 out.txt

我什至更改了目录,并且可以从任何地方访问。

现在问题来了,当我使用php时,我使用的代码如下:

echo exec("tesseract text.png out 2>&1", $output);
var_dump($output);

这次不是获取文件,而是说无法识别 tesseract!

这是输出:

operable program or batch file.
C:\wamp64\www\prestashop\ocr\ocr.php:12:
array (size=4)
  0 => string '' (length=0)
  1 => string 'C:\wamp64\www\prestashop\ocr>tesseract text.png out'    (length=51)
  2 => string ''tesseract' is not recognized as an internal or external command,' (length=65)
  3 => string 'operable program or batch file.' (length=31)

谁能帮帮我!?

谢谢

【问题讨论】:

    标签: php shell exec


    【解决方案1】:

    我有答案。我不知道为什么,但我必须重新启动 PC 才能让它与 PHP 一起工作

    【讨论】:

      【解决方案2】:

      好像没有设置windows环境变量PATH

      尝试重置PATH

      echo exec("PATH %PATH% && tesseract text.png out 2>&1", $output);
      var_dump($output);
      

      或从父会话中设置PATH

      echo exec("PATH ".getenv('PATH')." && tesseract text.png out 2>&1", $output);
      var_dump($output);
      

      希望这会有所帮助

      【讨论】:

        猜你喜欢
        • 2014-04-21
        • 2015-08-18
        • 2018-10-06
        • 1970-01-01
        • 2011-08-03
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多