Hi,
I wrote a very simple ping script to verify the host is reachable or not.
[CODE]$host = “yahoo.com”;
//$name = gethostbyaddr($ip);
$str = system(“ping -n 1 $host”);
echo ‘<br><br>’;
If (strstr($str, ‘Reply’) == TRUE) {
echo “<font color=’red’><b>$host</b> is REACHABLE</font>” ;
}
Else {
echo “<font color=’red'<b>$host</b> is UNREACHABLE</font>”;
}
What happen is I just want it to echo either $host is REACHABLE or UNREACHABLE. I use $str = system(“ping -n 1 $host”); to store the output result and read from it, but somehow the page keep showing the Ping Result also. Like below:
[QUOTE]
Pinging yahoo.com [216.109.112.135] with 32 bytes of data: Reply from 216.109.112.135: bytes=32 time=82ms TTL=54 Ping statistics for 216.109.112.135: Packets: Sent = 1, Received = 1, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 82ms, Maximum = 82ms, Average = 82ms
yahoo.com is UNREACHABLE
If there is a way to disable echo for $str = system(“ping -n 1 $host”); ? or filter the ping result out and just echo the REACHABLE and UNREACHABLE condition?
Thanks in advance.