Home > Linux, Programming > ip ping in bulk batch shell script

ip ping in bulk batch shell script

September 30th, 2010


Imagine,you’ve got a task now to verify a bulk of domains the speed of response and  whether they are active or not.Here a bulk of,means,for example,1,000.On getting this task,what will you do next?Type in every ip in the command line in Microsoft’s cmd and waits for the result?1,000,you must consider it.You may imagine,how tired after you’ve pinged the full 1,000 of the urls.

Here is my implement of the task.Firstly,put the urls in domain.txt,one url per line.Then run the script:sh if.sh.Lastly,waits for the result in ip.txt.During the execution time,you may go out and breath fresh air or have a cup of tea,not type in the Microsoft cmd any more!

Now,have a try by yourself!

if.sh:
#!/bin/bash
#copyright:doxer.org
rm -rf ./ip.txt
for i in `cat ./domain.txt`
do
echo -e ‘BEGIN\n\n’ >>ip.txt
ping $i -c 3 >>ip.txt
echo -e ‘\n\nEND\n’ >>ip.txt
done

Put your list of domains in the file:
xx1.com
xx2.com
xx3.com
xx4.com

Now,please use cat ip.txt to see the joyful result!

PS:

I have known that the script in this article ping host one by one for 3 years(now is 2013). So I’ve written an upgraded rpm package called pping_doxer, which pings hosts in parallel and proves to be very efficient. You can read more about it on http://www.doxer.org/projects-doxer/.


support_me
Amounts
  1. Gotozero
    April 24th, 2012 at 11:35 | #1

    Thanks a lot!

  1. No trackbacks yet.