shell_exec returns empty string

前端 未结 4 1952
隐瞒了意图╮
隐瞒了意图╮ 2021-01-21 03:06

When I execute my command in PHP with shell_exec it always returns an empty string. I tried shell_exec(\'ls -l\'); and it works. I put the command as

4条回答
  •  逝去的感伤
    2021-01-21 03:36

    I changed the sudoers to ALL ALL = (ALL) :NOPASSWD ALL (very un-secure, but just to find something sure to work),

    then I did a

    sudo -u myusername /path/to/script.sh

    where script.sh has export VAR=value export VAR=value

    for all the environmental variables that are necessary (you can do a printenv from a user who can properly pacmd to see what you need. probably a good HOME and maybe an XAUTHORITY).

    hope that helps

提交回复
热议问题