Re: re:Pinging from php srcipt

From: Date: Wed, 16 Aug 2000 04:37:14 +0000
Subject: Re: re:Pinging from php srcipt
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-11914@lists.php.net to get a copy of this message
Lars Torben Wilson wrote: > Joseph H Blythe writes: > > Cool thanks :-) > > > > I have played around with this after reading the ping man page. Does anyone > > know if you can get ping to output only the average and nothing else, or > > will I have to write a complex script to parse the output to only grab the > > average? > > > > My local version of ping doesn't offer this option, but here's a > (*very*) quick-and-dirty method: > > <?php > $host = 'www.thebuttlesschaps.com'; > if (!$result = ping -c 3 -q $host) { > echo "Unknown host\n"; > } else { > /* The only slashes that show up ni the output are those right > * around the information we want, so split it up on that. */ > $result = explode('/', $result); > $result = $result[3]; > echo "Average ping time: $result\n"; > } > ?> > Hey this works great, but how do I supress the output from the system command? Mutch appreciated :-) Joseph Blythe

« previous php.general (#11914) next »