[c-nsp] Scripting Multiple Pings?

lee.e.rian at census.gov lee.e.rian at census.gov
Fri Jul 29 00:20:10 EDT 2005


Austin McKinley <amckinle at andrew.cmu.edu> wrote on 07/28/2005 10:32:16 PM:
> I'd like to have a text file, full of commands like:
>
> ping 1.1.1.1
> ping 2.2.2.2
> ...
> ...
> ...
>
> and so on. Then I could test connectivity to all the interfaces I'm
> concerned about by pasting this text file, and looking at the results.
> The problem is that only the first ping runs, because the others all get
> thrown to the command line while the first ping runs. Anyone know a way
> around this behavior, without using expect/perl?

Maybe instead of pasting the text you need to give the file to a shell:

% cat x
ping 10.1.1.1
ping 10.1.1.2
ping 10.1.1.3
% sh x
10.1.1.1 is alive
no answer from 10.1.1.2
10.1.1.3 is alive
%

And you might want to list only the ping failures.  Something along the
lines of

for DEV in $addresses
do
/usr/sbin/ping $DEV 2 > /dev/null
stat=$?
if [ $stat -ne 0 ]; then
   /usr/bin/echo "\n$DEV \t*** no response ***"
fi
done


Lee



More information about the cisco-nsp mailing list