开发者

mkdir command doesn't work using exec() in PHP

开发者 https://www.devze.com 2023-02-24 19:41 出处:网络
This is strange. Although basic 开发者_如何学Pythoncommands such as ls, date, whoami are working. I cant seem to make a directory using the mkdir command using exec

This is strange. Although basic 开发者_如何学Pythoncommands such as ls, date, whoami are working. I cant seem to make a directory using the mkdir command using exec

$output=exec("mkdir helloworld");

Also it is worth asking, if such an error is occurring. is there any parameter or i can use to capture this error. Like the example below?

exec("mkdir helloworld 2>&1",$output,$return_val)
if($return_val !== 0) 
echo "there was an error"


this is most probably due to missing file priviliges of the user that is executing the code (the apache-user in many cases). If you add " 2>&1" to your command, you can also see the error output in $output

0

精彩评论

暂无评论...
验证码 换一张
取 消