Like many others I have problem with shell_exec() function in PHP.

I will run the file via browser not in terminal Below script not working for me i got output null actually i want to get dir and create txt in that dir with some given content. phpinfo() showing this result for me safe_mode Off Off Here is the scipt:

<?php

$output = shell_exec('vuserinfo someone@domainname.com');
echo "<pre>$output</pre>";

?>

output

echo $output : i got "" empty as output nothing returned

Please help me. I'm running PHP 5.3.10 on Apache2. My OS is windows

有帮助吗?

解决方案

I assume that you are receiving empty string as a result, correct? ($output == "")? Please check if you are not running this command in PHP safe mode: http://pl1.php.net/manual/en/features.safe-mode.php, http://pl1.php.net/manual/en/ini.sect.safe-mode.php. shell_exec() is disabled when running in safe mode.

You may also check output of:

<?php
phpinfo();
?>

It should list your PHP settings.

Please inspect Windows event log on your host. Look for any unsuccessful operations (lack of access rights in the moment of doing this shell_exec()).

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top