Re: Ping Script

From: Sam Munzani (sam@xxxxxxxxxxxx)
Date: Tue Aug 27 2002 - 15:20:39 GMT-3


   
Here is a simple korn shell script. You can get more fancy with scripting
based on your needs.

#!/usr/bin/ksh
for ip in $(cat iplist) #Where iplist is the file name where you have listed
all your ip addresses.
do
ping $ip
done > output.txt

It will read the ip addresses from "iplist" file and ping them. The output
will be saved in output.txt file. Your "iplist" file contains your ip
addresses in each line.
1.1.1.1
2.2.2.2
3.3.3.3

If you are feeding your /etc/hosts file from your unix box to the script.
Following script will do the trick.
#!/usr/bin/ksh
while read line
do
echo $line | read ip host junk
ping $ip
done < /etc/hosts > output.txt

It reads one line at a time from /etc/hosts. Usually first field in
/etc/hosts is IP address. So it will ping the host by ip address. This
script is not catching any comments line. You can write your routine to
ignore the comments line also.

Hope this helps.

Sam Munzani
CCIE # 6479

> People talk about using "ping scripts"fFor testing. Can anyone please tell
> me how to do this.
>
> I want to be able to check connectivity to about 20 ip addressese without
> having to type indiviual "ping 1.1.1.2" etc
>
>



This archive was generated by hypermail 2.1.4 : Sat Sep 07 2002 - 19:48:39 GMT-3