LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   php command execution problem (https://www.linuxquestions.org/questions/programming-9/php-command-execution-problem-283976/)

avswamy 01-30-2005 02:52 AM

php command execution problem
 
i am trying to execute this script, while executing this scrip i am not getting the output, my php version is 4.3.7 and linux version is FEDORA 2.
While with print command it is showing ping -c 4 172.50.0.101, is it executing or not. if executing then why it is not showing the output on browser. while i tried to enter more than 10 in count, it is showing the error as max count is 10, so the script upto some point is executing. I am not able to find it is stucking, can any one help me out in this. I am able to execute the same script in windows without any problem. While using same with Linux box in Fedora is giving problem. Here i am using with default configuration, and test.php with phpinfo(); it is showing test page.

Thank you all for the so much of info.


<?php
$max_count = "10"; //maximum count for ping command
$cmd = "ping -c"; // unix (unix means all flavors of linux as well)
//$cmd = "ping -n"; // windows
//$cmd = "tping -c"; // netware
// -------------------------
//
// nothing more to be done.

If (isset($_POST['submit'])) {
If ($_POST['count'] > $max_count)
{
echo 'Maximum for count is '.$max_count;
echo '<a href="10.10.0.12">Back</a>';
$again = True;
}
else
{
If (ereg(" ",$_POST['host']))
{
echo 'No Space in Host field allowed !';
echo '<a href="10.10.0.12">Back</a>';
$again= True;
}
else
{
echo("<b><font color=\"00cf10\">Connectivity Test to a Subscriber in Zone I Output:</font></b><br>");
echo("<pre>");
// $host = escapeshellarg($_POST['host']);
// $count = escapeshellarg($_POST['count']);
$host = $_POST['host'];
$count = $_POST['count'];
print"$cmd $count $host";
system("$cmd $count $host", $list);
echo("</pre>");
}
}
}
else
{

?>

<html>
<title>This site is Designed and Maintained by Swamy</title>
<body>
<h3><font color=\"00cf10\">Connectivity Test to a Subscriber in Zone I</font></h3>
<h4><font color=\"00cf8\">IP Address in Banjara Hills, series should be ---172.25.0.0</font></h4>
<h4><font color=\"00cf8\">IP Address in Khairatabad/Somajiguda/Erramanzil, series should be ----172.26.0.0</font></h4>
<form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">
Enter IP or Host <input type="text" name="host"></input>
Enter Count <input type="text" name="count" size="2" value="4"></input>
<input type="submit" name="submit" value="Test"></input>
</form>
<?php
}
?>
<a href="/downloads/index.php"><img src=images/alerts.gif width=36 height=35 border=1 alt="Downloads"></a>
</body></html>
php command execution problem

Hko 01-30-2005 06:44 AM

Your script runs without problems after copy/paste verbatim on my Debian PC with Apache 1.3.33 and PHP 4.3.10.

Maybe you're system uses a "ping" that doesn't support the command line switches you use? I can't think of something else.

Have you tried to run the "ping" command as output by: print"$cmd $count $host"; ?

avswamy 01-31-2005 04:30 AM

yes it is printing as
ping -c 4 172.20.0.1

i think, the command is not executing.

avswamy 01-31-2005 04:55 AM

It has to display after ping -c 4 172.25.0.1

this
Pinging 61.246.213.206 with 32 bytes of data:

after this i should get Reply----but i am not getting this display


All times are GMT -5. The time now is 11:02 AM.