This is the output I get and you can see that on the lines where the loss is
0% it still says 100%
1 - Pinging 10.200.26.1 with 32 bytes of data:
2 - Request timed out.
3 - Ping statistics for 10.200.26.1:
4 - Packets: Sent = 1, Received = 0, Lost = 1 (100% loss),
100% loss
5 - Approximate round trip times in milli-seconds:
6 - Minimum = 0ms, Maximum = 0ms, Average = 0ms
1 - Pinging 10.42.71.1 with 32 bytes of data:
2 - Reply from 10.42.71.1: bytes=32 time10ms TTL=255
3 - Ping statistics for 10.42.71.1:
4 - Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),
100% loss
5 - Approximate round trip times in milli-seconds:
6 - Minimum = 0ms, Maximum = 0ms, Average = 0ms
1 - Pinging 10.200.48.1 with 32 bytes of data:
2 - Request timed out.
3 - Ping statistics for 10.200.48.1:
4 - Packets: Sent = 1, Received = 0, Lost = 1 (100% loss),
100% loss
5 - Approximate round trip times in milli-seconds:
6 - Minimum = 0ms, Maximum = 0ms, Average = 0ms
1 - Pinging 10.42.1.1 with 32 bytes of data:
2 - Reply from 10.42.1.1: bytes=32 time=78ms TTL=254
3 - Ping statistics for 10.42.1.1:
4 - Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),
100% loss
5 - Approximate round trip times in milli-seconds:
6 - Minimum = 78ms, Maximum = 78ms, Average = 78ms
Christopher J. Crane [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
I am trying to get a script to work. The basic idea is to go into a
database
and grab some IP addresses for my LAN. Then for each one ping it using the
exec command 1 time. If it is successful print output in green and if it
is
not, print output in red. This is being done on a Win32 system. The ping
command returns 6 lines for each IP address. I want to take line 4 and see
if the result is 100% loss or 0% loss. Below is what I have, but it
only
seems to keep the first value and prints it out all the way through. I
know
it's a problem with the looping somewhere, I just can't figure it out.
?php
mysql_connect(localhost, root, ) or die(Could not connect);
mysql_select_db(Network);
$Result = mysql_query(SELECT DISTINCT Subnet,SerialIPAddress FROM
Locations) or die(Invalid query);
$output = array();
while ($Location = mysql_fetch_assoc($Result)) {
// ping some server five times and store output in array $output
exec(ping . $Location[Subnet] . -n 1, $output);
$Count = 0;
while (list(,$val) = each($output)) {
if($val != ) {
$Count++;
print $Count - $valbr\n;
if($Count == 4) {
list($Junk1, $Results1) = split(\(, $val);
list($Results2, $Junk2) = split(\), $Results1);
if($Results2 = 100% loss) { print font
color=\red\$Results2/fontbr\n; }
else { print font color=\green\$Results2/fontbr\n; }
}
}
}
print hr\n;
}
mysql_free_result($Result);
mysql_close();
?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php