How can I ping a list of 70 ip addresses?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jclarkkent2003
Forum Contributor
Posts: 123
Joined: Sat Dec 04, 2004 9:14 pm

How can I ping a list of 70 ip addresses?

Post by jclarkkent2003 »

Hi guys,
How can I ping a list of 70 ip addresses? I need to ping 70 ip addresses I binded to my server to make sure they are all online.

How would I do that most easily? Is there a way to do it in php or how can i do it totally?

ip_list.txt content's
66.66.66.10
66.66.66.11
66.66.66.12
66.66.66.13

66.66.70.70
66.66.70.71
66.66.70.72
66.66.70.73
66.66.70.74

66.66.110.210
66.66.110.211
66.66.110.212
66.66.110.213

etc...

Thanks in advance, this is important!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

exec()
jclarkkent2003
Forum Contributor
Posts: 123
Joined: Sat Dec 04, 2004 9:14 pm

Post by jclarkkent2003 »

lol, now i feel stupid.....

Thanks mate~

Oh hold up, how about on a windows xp sp 2 pro computer using xampp? I don't think that works quite right.

Code: Select all

<?
set_time_limit(600); // Ten minutes
$string = "http://www.dnsstuff.com/tools/ping.ch?ip=";
$file = file("ip_list.txt");

for($k=0;$k<sizeof($file);$k++)
{

$ip = $file[$k];

exec("ping $ip"); flush();ob_flush();

//$full_ping_url = $string.$ip;
//include("$full_ping_url");

}

?>
That didn't output the ping response and ttl time... Did i miss something? Thansk~
User avatar
raghavan20
DevNet Resident
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:

Post by raghavan20 »

try

Code: Select all

var_export(exec())
because...
PHP Manual wrote: output

If the output argument is present, then the specified array will be filled with every line of output from the command. Trailing whitespace, such as \n, is not included in this array. Note that if the array already contains some elements, exec() will append to the end of the array. If you do not want the function to append elements, call unset() on the array before passing it to exec().
Post Reply