Re: [PHP] Checking if a host is online

From: Adam Maas (mykroft_at_mykroft.com)
Date: 11/29/03


Date: Sat, 29 Nov 2003 12:20:32 -0500
To: Jason Giangrande <jason@giangrande.org>

Jason Giangrande wrote:
> I'm creating an application for an Intranet that, among other things, is
> supposed to check to see if particular hosts are online, and if so, what
> their IP address is. Anyone know how I can accomplish this? I tried
> using exec("host $host"); (where $host is the hostname) and while this
> gets the IP it gets the IP address sometimes even if the host is not
> active, because a DNS record for the system still exists. I also looked
> into the gethostbyname() function, but that has similar problems to
> using the external host command. I also tried to use an external ping
> command (ping -c 1 $host), and while I could get that to work, since it
> returns non-zero status if the host can not be contacted, it takes quite
> a while to execute for even a few hosts at once.
>
> Anyone ever do this king=d of thing before or have any suggestions on
> what might work?

why not try:

  passthru("ping $host");

Adam



Relevant Pages

  • Re: [PHP] Checking if a host is online
    ... It's not written in PHP from what I remember. ... > supposed to check to see if particular hosts are online, and if so, what ... > using the external host command. ...
    (php.general)
  • Checking if a host is online
    ... I'm creating an application for an Intranet that, among other things, is ... supposed to check to see if particular hosts are online, and if so, what ... using exec("host $host"); and while this ... using the external host command. ...
    (php.general)
  • Re: RSG Events: Why You Should Play
    ... You say you can determine that by their online persona. ... the host of a RSG event with your petty differences from online. ... Further, one reason for ... individual to attend would have cost me that small joy. ...
    (rec.sport.golf)
  • Re: RSG Events: Why You Should Play
    ... One of the others posted a loaded question to the host of the event. ... But part of why people go to these events is to golf with people they like, and to spend time with them. ... So they ask to be paired up with long-time buds, or people they've come to know online. ...
    (rec.sport.golf)
  • Re: RSG Events: Why You Should Play
    ... You say you can determine that by their online persona. ... We also differ in another area. ... the host of a RSG event with your petty differences from online. ...
    (rec.sport.golf)