FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > CentOS > CentOS

 
 
LinkBack Thread Tools
 
Old 07-28-2008, 11:50 AM
Gopinath Achari
 
Default Shell script - ping

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


_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 07-28-2008, 11:57 AM
Laurence Alexander Hurst
 
Default Shell script - ping

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
 
Old 07-28-2008, 01:11 PM
"Javor Nikolov"
 
Default Shell script - ping

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
 
Old 07-28-2008, 03:36 PM
Bill Campbell
 
Default Shell script - ping

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
--
INTERNET: bill@celestial.com Bill Campbell; Celestial Software LLC
URL: http://www.celestial.com/ PO Box 820; 6641 E. Mercer Way
Voice: (206) 236-1676 Mercer Island, WA 98040-0820
Fax: (206) 232-9186

A tax-supported, compulsory educational system is the complete model of the
totalitarian state. -- Isabel Paterson, God of the Machine
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 07-28-2008, 04:18 PM
Mike
 
Default Shell script - ping

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



_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 07-28-2008, 05:06 PM
Lorenzo Martínez Rodríguez
 
Default Shell script - ping

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,



--



Lorenzo Martínez Rodríguez
Consultor de seguridad informática




_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 07-28-2008, 05:15 PM
"kapil singh"
 
Default Shell script - ping

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
" $host
else
printf "%-30s is not alive
" $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)



--
Thanks and Regards,
Kapil Singh Kushwah

Linux System Administrator
Hotwax Media Inc.
Indore,(M.P) INDIA



_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 07-29-2008, 05:09 AM
Gopinath Achari
 
Default Shell script - ping

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


_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 07-30-2008, 06:50 AM
Hywel Richards
 
Default Shell script - ping

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
" $1
else
printf "%-30s is not alive
" $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.



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

Thread Tools




All times are GMT. The time now is 11:45 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2007 - 2008, www.linux-archive.org