Re: re:Pinging from php srcipt
| From: | Lars Torben Wilson | Date: | Wed, 16 Aug 2000 04:49:22 +0000 |
| Subject: | Re: re:Pinging from php srcipt | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-11916@lists.php.net to get a copy of this message | ||
Joseph H Blythe writes:
> Lars Torben Wilson wrote:
> > <?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
There is no system() command--just use backticks around the ping
command, and all of its output is assigned to $result. (Make sure
they're backticks, and not regular single quotes). For more
information on backticks, check out:
http://www.php.net/manual/language.operators.execution.php
Cheers,
Torben
--
+----------------------------------------------------------------+
|Torben Wilson <torben@php.net> Netmill iTech|
|http://www.coastnet.com/~torben http://www.netmill.fi|
|Ph: 1 250 383-9735 torben@netmill.fi|
+----------------------------------------------------------------+