I am trying to make a few php scripts that will run among other things system calls commands like top and other custom scripts. You can see the code below is super simple. The problem that we are having with the php below is that when I call the php from the linux prompt like:
#php checkTOP.php
it will return the top -n 1 output in the screen no problem there.
When I run the script from the webserver using the http://url.com/checkTOP.php it only returns the following:
program:/usr/bin/top -n 1 ver1 = retval = 1 Returned not zero
Which is my debugging statements.
<?php
$program="/usr/bin/top -n 1";
echo "program:{$program}<br /> \n";
$ver1=system($program,$retval);
echo "ver1 = {$ver1}<br />\n";
echo "retval = {$retval}<br /> \n";
if($retval==0)
{
echo "Returned 0<br />\n";
}
else
{
echo "Returned not zero <br />\n";
}
die;
?>
Change 1: One more thing. All permissions are set correctly /usr/bin/top is set root:apache with rxrxrx and also all the directories /usr/bin.