Re: ping...

From: Date: Fri, 13 Dec 2002 10:26:52 +0000
Subject: Re: ping...
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-128145@lists.php.net to get a copy of this message
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? */

« previous php.general (#128145) next »