【问题标题】:Commands working fine in putty but not using exec() in PHP命令在 putty 中工作正常,但在 PHP 中不使用 exec()
【发布时间】:2017-05-03 12:55:49
【问题描述】:

所以我在我的 VPS (Ubuntu 14.04.5) 上安装了 shhavel 的 facerec (https://github.com/shhavel/facerec),当我在 putty 中使用它时它工作得非常好:

facerec list
jenniferlawrence
emmawatson

但是,在 PHP 中使用 exec() 函数时,唯一有效的命令是 facerec -help,所有其他命令都会产生类似以下的错误:

facerec 列表 2>&1

Traceback (most recent call last):
File "/usr/local/bin/facerec", line 359, in 
sys.exit(__main__())
File "/usr/local/bin/facerec", line 356, in __main__
return args.func(args)
File "/usr/local/bin/facerec", line 159, in list
for subject in os.listdir(subjects_directory):
OSError: [Errno 2] No such file or directory: './subjects'

PHP 脚本:

exec('facerec list 2>&1', $output);
foreach($output as $string) {
    echo $string."<br>";
}

我该如何解决这个问题?

【问题讨论】:

  • 您确定您的 php 脚本具有使用 exec 运行这些命令的正确权限吗?

标签: php linux ubuntu terminal


【解决方案1】:

发现问题:

“主题”文件夹位于 PHP 脚本无权访问的 /root/ 中

可能的解决方案:

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-07-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多