Page 1 of 1
Executing system commands through PHP code
Posted: Thu May 18, 2006 3:11 am
by Newfriend
I have problem in executing exec() on browser.
I could run a php program that includes exec() using command line execution of PHP, the same program is not working from the browser.
Re: Executing system commands through PHP code
Posted: Thu May 18, 2006 7:21 am
by Chris Corbyn
Newfriend wrote:I have problem in executing exec() on browser.
I could run a php program that includes exec() using command line execution of PHP, the same program is not working from the browser.
On command line PHP uses the userid of the person executing the code and thus, has those privileges. In a browser PHP runs under the userid of the HTTPd user and thus only has those privileges. Basically, check your permissions on the executable file

Posted: Wed May 24, 2006 1:03 am
by Newfriend
I checked out all those permission. Its proper.
I am giving u a smaple code where I exactly have the problem.
<?
exec("iptables -L",$out,$ret)
if($ret==0)
{
for($i=0;$i<count($out);$i++)
print(" $out[$i] ");
}
?>
This code is listing all the rules in iptables when executed from command prompt. But no output from browser.
I am working at root, I have all privilages.
Please help me.
Posted: Wed May 24, 2006 1:15 am
by timvw
This would imply that your webserver also runs under the root account... which is just really wrong..