[CentOS] Shell script - ping

Javor Nikolov nikolov.javor at gmail.com
Mon Jul 28 13:11:53 UTC 2008


Hi,

If you you want a quicker execution - you could also run the pings to
separate hosts in parallel starting the jobs in background (&) and waiting
for them with "wait" after that. You'll have to be more careful about the
outputs in that case - e.g. redirect them to separate files.

Regards,
Javor

On Mon, Jul 28, 2008 at 2:57 PM, Laurence Alexander Hurst <
L.A.Hurst at lboro.ac.uk> wrote:

> 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
>
> _______________________________________________
> CentOS mailing list
> CentOS at centos.org
> http://lists.centos.org/mailman/listinfo/centos
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.centos.org/pipermail/centos/attachments/20080728/6dbfa06e/attachment.html>


More information about the CentOS mailing list