Re: re:Pinging from php srcipt
| From: | David Robley | Date: | Wed, 16 Aug 2000 04:40:57 +0000 |
| Subject: | Re: re:Pinging from php srcipt | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-11915@lists.php.net to get a copy of this message | ||
On 16 Aug, Joseph H Blythe wrote:
> 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
In that case, I think you could try exec() rather than system().
Cheers
--
David Robley | WEBMASTER & Mail List Admin
RESEARCH CENTRE FOR INJURY STUDIES | http://www.nisu.flinders.edu.au/
AusEinet | http://auseinet.flinders.edu.au/
Flinders University, ADELAIDE, SOUTH AUSTRALIA