shell_exec() returning null on “ls”

后端 未结 1 1055
星月不相逢
星月不相逢 2020-12-08 15:09

So I have this code and I\'m only trying to make a list of the saves in another directory where the php scrip is in xampp folder and the saves are to this path /root/f

相关标签:
1条回答
  • 2020-12-08 15:27

    Add 2>&1 to the end of your shell command to have STDERR returned as well as STDOUT.

    $output = shell_exec("ls /root/files/saves 2>&1");
    

    Also, if the user running PHP doesn't have sufficient permissions to view the output in /root/, the above code will return a Permission denied error message.

    Source: http://php.net/manual/en/function.shell-exec.php#28994

    0 讨论(0)
提交回复
热议问题