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
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
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@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@centos.org http://lists.centos.org/mailman/listinfo/centos
thank u all
On Mon, 2008-07-28 at 16:11 +0300, Javor Nikolov wrote:
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@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@centos.org http://lists.centos.org/mailman/listinfo/centos
CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
On Mon, Jul 28, 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
If your goal is to test connectivity, you might look at the perl Net::Ping module. ``perldoc Net::Ping'' has several examples of checking one or more systems to see if they are alive.
BTW: Anybody know of a python equivalent to this?
Bill
Bill Campbell escribió:
On Mon, Jul 28, 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
If your goal is to test connectivity, you might look at the perl Net::Ping module. ``perldoc Net::Ping'' has several examples of checking one or more systems to see if they are alive.
BTW: Anybody know of a python equivalent to this?
Bill
Hello,
I have done something before with nmap -sP <target> time ago. Later you can grep the response to know whether an IP address is alive or not.
Hope it helps,
I really like 'fping' for use in shell scripts. See: http://www.fping.com/ and http://fping.sourceforge.net/man/
It can be 'yum installed' from the CentOS RPMforge repo.
So in your script you can just do fping -c 10 <dest1> <dest2> ... <destN>
I don't understand exactly what 'scripts which launches 10 pings' and 'execution of single shell scripts' means. So don't think I can help with the scripting part...
On Mon, 28 Jul 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
Hello, This is a running shell script for ping multiple host it provides result directly: if host is successfully ping then it returns Host is alive. otherwise Host is not alive Try this i am working with that in my local n/w.
#/bin/bash for n in {1..5}; do host=192.168.1.$n ping -c2 $host &> /dev/null if [ $? = 0 ] ; then printf "%-30s is alive \n" $host else printf "%-30s is not alive \n" $host fi done
Note: 1.Replace ip with your ip range 2.Replace the no. of ip according to your need.(means value of n in for loop)
Can't resist posting the parallel version of this:
#!/bin/bash if [ "$#" == "1" ] then ping -c2 $1 &> /dev/null if [ $? = 0 ] ; then printf "%-30s is alive \n" $1 else printf "%-30s is not alive \n" $1 fi else for n in $* do $0 $n & done wait fi
This does the same thing as the parent post, but (a) takes the IP addresses as command-line arguments (i.e. call like this: "myscript 192.168.1.1 192.168.1.2 192.168.1.3"), and (b) dispatches the pings in parallel so that you get the response from all the hosts quicker.
The responses are displayed in the order they return, but you could put it through a sort if you wanted them ordered.