开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜