Jump to content


Photo

Ping a remote device to show whether it is on or offline


  • Please log in to reply
4 replies to this topic

#1 stephenmelody

stephenmelody
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 24 July 2006 - 11:38 AM

Hello All!

I am trying to develop an application that will ping a IP address or computer name from the database to return an online or offline image on the webpage depending on the ping results. ie if the ping returns the packet the page displays online, and if it doenst it displays offline.

If anyone has any idea on how to do this then I would be extremely grateful.

Cheers,

Steve.

#2 Kris

Kris
  • Staff Alumni
  • Advanced Member
  • 2,755 posts
  • LocationThe Internet

Posted 24 July 2006 - 12:02 PM

You can use system commands to do this on either Windows or *NIX with something like this:
<?php
exec("ping 192.168.1.1",$out);
echo "<pre>"; print_r($out); echo "</pre>";
?>


#3 stephenmelody

stephenmelody
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 24 July 2006 - 12:19 PM

I copied and pasted the code into a lovely new php page.

and it went all wrong and gave me this:

Warning: exec(): Unable to fork [ping 127.0.0.1] in C:\Inetpub\apps site\pinger\ping3.php on line 2

any clues?

Ta,

Steve

#4 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 24 July 2006 - 01:40 PM

Is php running in safe mode?

#5 ChaosXero

ChaosXero
  • Members
  • PipPipPip
  • Advanced Member
  • 80 posts

Posted 24 July 2006 - 01:43 PM

If it's a MySQL Server/Database you can use mysql_ping (or similar for other DB flavors).
http://us2.php.net/m....mysql-ping.php




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users