[英]php exec('alpr') returns an empty array with openALPR installed
I am writing a php script that makes use of openALPR installed on my linux computer. 我正在写一个使用我的Linux计算机上安装的openALPR的php脚本。
When I type "alpr --version" in the terminal, I get this output 当我在终端中键入“ alpr --version”时,得到此输出
alpr version: 2.2.4
But then when I do this in my php script, I get an empty array result. 但是,当我在php脚本中执行此操作时,我得到一个空数组结果。 But any other command works just fine.
但是任何其他命令都可以。
Here is my code snippet 这是我的代码片段
$command = 'alpr --version ';
$result = array();
exec($command, $result);
var_dump($result);
I will appreciate any help 我将不胜感激
You are probably running that command from the terminal as a different user. 您可能正在终端上以其他用户身份运行该命令。
Find out which user php and/or apache is using, then switch user in the terminal. 找出正在使用哪个用户php和/或apache,然后在终端中切换用户。
Try and run the command again. 尝试再次运行该命令。
If the command isn't found, switch back to yourself and type which alpr
, which will give you the path. 如果找不到该命令,请切换回您自己,然后键入
which alpr
,这将为您提供路径。
Then switch back to PHP's user, and ensure the $PATH environment variable includes the folder where the alpr
executable is found. 然后切换回PHP用户,并确保$ PATH环境变量包含在其中找到
alpr
可执行文件的文件夹。
Also, make sure that the executable is actually executable by that user/group. 另外,请确保该可执行文件实际上是该用户/组可执行的文件。 If not, you'll need to use
chmod
or chown
or chgrp
to give PHP permission. 如果没有,则需要使用
chmod
或chown
或chgrp
来授予PHP权限。
If you get stuck, leave a comment! 如果您被卡住,请发表评论!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.