简体   繁体   中英

PHP exec/shell_exec/system not working through browser

I am running an SCO Unix box with apache version 1.3.33 and PHP version 4.4. I can properly execute the exec command through the cli, but run into trouble with trying to execute the script via a browser. My settings are:

  • safe mode off
  • full read/write/exec permissions
  • displaying all errors
  • no disabled functions

My code: test_script.php in htdocs dir

<?php
exec('ls',$out,$rval);
echo "Output:<hr />";
print "<pre>"; print_r($out); print "</pre>";
echo "Return Value:<hr />";
echo $rval;
?>

I've tried setting the executable binary path explicitly also. The test script is the same User/Group as apache. I've also tried adding 2>&1 to the arg, but see no change. Thank you in advance.

See here for similar.

try

$output = shell_exec('ls /tmp/ 2>&1')

you might be having an issue with permissions to current directory for the user running the web page.

you can also try whoami command.

有时这些函数被禁用,你必须在php.ini中启用它们

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM