Ping<

liunx

Guest
Is there a way to ping a computer using only php commands? ie. if I dont have access to an external ping command.this is from <!-- w --><a class="postlink" href="http://www.php.net">www.php.net</a><!-- w -->:

<!-- m --><a class="postlink" href="http://uk.php.net/function.exec">http://uk.php.net/function.exec</a><!-- m -->


Using ping function in PHP
---------------------------------------

You can use the extended version of this program to check the network status and later you can add HTTP.FTP.POP3 and SMTP protocols as its part.

Access the content of exec from a variable, make radio buttons for each protocol and change the value of variable according to te radio button selection.

[Use ping with count and deadline]

<META http-equiv="Refresh" content="3">
<?php
$str=exec("ping -c 1 -w 1 192.168.1.216",$a,$a1);
print "<table>";
if(strlen($str)>1){
print"<tr><td bgcolor='#fff000'>present</td></tr>";
}else{
print"<tr><td bgcolor='#000000'>Not present</td></tr>";
}
print "</table> ";
?>To my understanding when you exec() a command the ability to run the command depends on the permissions of the user exec'ing the command. So would that not mean the user running the web server? which might be a priveledged user that has the rights to access ping. If not then the answer is no, to exec'ing anyways, as for internal php networking commands, dunno i haven't read that far yet :)

-flOriginally posted by Horus_Kol
this is from <!-- w --><a class="postlink" href="http://www.php.net">www.php.net</a><!-- w -->:

<!-- m --><a class="postlink" href="http://uk.php.net/function.exec">http://uk.php.net/function.exec</a><!-- m -->

To use exec() dont you need to have an external ping program? I need to do it without using an external program.don't you have a webserver?

wouldn't that have "ping" on it?


and another rummage at <!-- w --><a class="postlink" href="http://www.php.net">www.php.net</a><!-- w --> gives this chapter:

<!-- m --><a class="postlink" href="http://uk2.php.net/sockets">http://uk2.php.net/sockets</a><!-- m -->


look in the user notesping is on both unix and windows systems, im not sure about ancient windows but i know it is in me/nt/2k/xp for sure, and most likely in 98 and possibly 95...

either way, it's included on most OS's that support networking.

syntax: ping [flags] <hostname>

you dont need the flags in order to do a basic ping test

and most machines by default have the ping binary available to all users unless the admins change it on purpose.

-fl
 
Back
Top