简体   繁体   中英

PHP exec() function windows 7 IIS 7.5

I am trying to run an a command line util using exec() but it doesnt return anything. I have read on php.net that the permissions on cmd.exe need to be set to allow the iis user to run it. I have not been able to do this using any method I can think of. cacls icacls and the standard security screen dont work. I am logging the output to a mysql database.

my code looks like this:

$Ret = array();
$err = "";
exec("dir", $Ret, $err);

in the db I get array for $Ret

Either something is wrong with the command, I doubt it, or I need to set the permissions somehow.

Please help.

Change the line:

exec("dir", $Ret, $err);

to:

$r = exec("dir", $Ret, $err);
echo $r;

You need to capture the return value of exec into a variable then render that.

Or try running this:

<?php
$a = array();
$e = "";

echo "exec'ing<br/>";
$r = exec("dir", $a, $e);

echo "var_dumping<br/>";

var_dump($a);

echo "=====================\n";

var_dump($e);

echo "=====================\n";

var_dump($r);

?>

If you're running this in a browser with xdebug turned off then you might need to view-source to see the results.

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