tonelm54
asked on
PHP Ping
Good morning,
Ive been trying to get a Ping working on a server, just to test if a particular server is up and working.
Ive tried system, exec, and passthru but get the error messeage:-
Warning: EXEC functions have been disabled for security reasons.
I have managed to get the following code working on my web and mail servers:-
Is it possible to open a socket up to a server that doesnt have a web or mail server on? Prefebably a ping request, but I know Pings work differently to this my using ICMP instead of TCP or UDP.
Thank you
Ive been trying to get a Ping working on a server, just to test if a particular server is up and working.
Ive tried system, exec, and passthru but get the error messeage:-
Warning: EXEC functions have been disabled for security reasons.
I have managed to get the following code working on my web and mail servers:-
<?php
$fp = fsockopen ("87.105.128.62", 25, $errno, $errstr, 30);
if (!$fp) {
echo "Failed";
} else {
echo ('Pinged OK');
fclose ($fp);
}
?>
Is it possible to open a socket up to a server that doesnt have a web or mail server on? Prefebably a ping request, but I know Pings work differently to this my using ICMP instead of TCP or UDP.
Thank you
ASKER
Sorry, trying the shell_exec, I still get:-
Warning: EXEC functions have been disabled for security reasons in /home/vincienergies/7KEXM7 KR/htdocs/ testPing.p hp on line 2
Warning: EXEC functions have been disabled for security reasons in /home/vincienergies/7KEXM7
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You can also try thsi:
http://www.codediesel.com/php/ping-a-server-using-php/
http://www.codediesel.com/php/ping-a-server-using-php/
try this
$strPing= `ping -ns www.whatever.com 4 4`;
echo "<pre>";
echo $strPing;
echo "</pre>";
OR
<?
$host='CHANGETHISTOYOURHOS T';
$strPing= `ping $host`;
$posstring = strpos($strPing, "Please", 1);
if ($posstring == 0)
{ echo "Server online!"; }
else
{ echo "Server offline!"; }
?>
$strPing= `ping -ns www.whatever.com 4 4`;
echo "<pre>";
echo $strPing;
echo "</pre>";
OR
<?
$host='CHANGETHISTOYOURHOS
$strPing= `ping $host`;
$posstring = strpos($strPing, "Please", 1);
if ($posstring == 0)
{ echo "Server online!"; }
else
{ echo "Server offline!"; }
?>
<?php
$output = shell_exec('ping www.google.com');
echo "<pre>";e
cho $output;?>
refer
http://php.bigresource.com/Track/php-wc8hpzxd/