[CentOS] Shell script - ping
Laurence Alexander Hurst
L.A.Hurst at lboro.ac.uk
Mon Jul 28 11:57:19 UTC 2008
Gopinath Achari wrote:
> hi,
>
> how to write a scripts which launches 10 pings to different
> destinations at execution of single shell scripts
>
> please help me any ideas
>
> regards,
> Gopinath
Do you mean something like:
ping -c10 host1
ping -c10 host2
....
which will ping host1 10 times, then host2 10 times etc. (see `man ping`
for details of the options).
If you have a list of hosts in a file, you could do:
for host in `cat [filename]`
do
ping -c10 $host
done
or:
while read host
do
ping -c10 $host
done << [filename]
If you only want to ping each host once, you can substitute '-c10' with
'-c1' (again, see the man page).
Hope this helps
Laurence
More information about the CentOS
mailing list