首页 > 解决方案 > PHP Exec sudo mount 抛出花哨的错误消息

问题描述

我正在使用 Centos7 操作系统,我有这个从 Windows PC 挂载文件夹的脚本

exec('sudo mount -t cifs -o username="'.$user.'",password="'.$pass.'",dir_mode=0777,file_mode=0777 
//'.$ip_address.'/c/kitpos/update /mnt 2>&1',   $output, $results);

我收到了这个看起来像权限问题的奇特错误消息。

Array
(
    [0] => 
    [1] => We trust you have received the usual lecture from the local System
    [2] => Administrator. It usually boils down to these three things:
    [3] => 
    [4] =>     #1) Respect the privacy of others.
    [5] =>     #2) Think before you type.
    [6] =>     #3) With great power comes great responsibility.
    [7] => 
    [8] => sudo: no tty present and no askpass program specified
)

我的 /mnt 文件夹所有权和权限是root777但即使我更改它 www-data:www-data 这是我的 php 运行,仍然得到同样的错误。

777 drwxrwxrwx 2 root root 4096 mnt

我也有一个 Ubuntu 服务器,但它在使用相同的代码时运行良好。有人有想法吗?

标签: phpunixcentos

解决方案


推荐阅读