PHP, ping a list of IPs?
I have a list of IPs which I want to ping via PHP (to save me the trouble of manually doing it via SSH).
I can run exec, escapeshellarg, system etc on my server - how would I create a script to ping an IP once and return the response time?
Any h开发者_如何学JAVAelp would be greatly appreciated.
Thank you :)
Using shell_exec
, like this:
$output = shell_exec('ping -n 1 127.0.0.1');
print $output;
If you want to use the shell ping, use shell_exec
for this.
However...here you can find an excellent example on how to ping via PHP:
http://birk-jensen.dk/2010/09/php-ping/
This script can be easily adapted with php timers to return response times.
精彩评论