On Friday 13 December 2002 18:02, Brian McGarvie wrote:
> I can exec ping OK... but I need a way to ping and basically give me a OK
> or Not OK... any ideas?
So you have something like:
$result = `ping -c 3 www.example.com`;
echo $result;
Then you have to parse $result to work out whether the pings are successful or
not.
-------------------------------------------------------------------------
PING www.example.com (10.0.0.1) from 10.0.0.2 : 56(84) bytes of data.
64 bytes from www.example.com (10.0.0.1): icmp_seq=1 ttl=224 time=466 ms
64 bytes from www.example.com (10.0.0.1): icmp_seq=2 ttl=224 time=477 ms
64 bytes from www.example.com (10.0.0.1): icmp_seq=3 ttl=224 time=465 ms
--- www.example.com ping statistics ---
3 packets transmitted, 3 received, 0% loss, time 2001ms
rtt min/avg/max/mdev = 465.948/469.969/477.728/5.515 ms
-------------------------------------------------------------------------
The simplest measure would be how many packets transmitted and how many
received. So something along the lines of:
(preg_match("/^(\d{,}) packets transmitted, (\d{1,}) received,.*$/im",
$result, $matches))
might work. Untested, so use with extreme caution.
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
/*
The debate rages on: Is PL/I Bachtrian or Dromedary?
*/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php