Re: Shell script - ping

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



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@xxxxxxxxxxx> 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@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos

_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos

[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux