[rancid] Re: Newbie Question...sorry!

Chris Stave cstave at gmail.com
Mon Oct 15 15:57:35 UTC 2007


I've made a script to call clogin, our devices are numbered fairly
sequentially, from 10.0.0.1 to 10.0.0.86 with cluster members getting
10.0.1.x and 10.0.2.x , etc...
I put whatever commands I want to run into cmds.txt and then make sure that
the switches I want those commands run on are represented in the script.  A
slight change to this would be to put the actual command you want to run in
in place of the cmds.txt, which would make it easy to specify the ip address
as a filename for the log.

This obviously works better if your devices are all similarly numbered.

I've appended the script, but do note that it won't work for you without
changes, but just as an example of how I did it.  I suspect that there is a
cleaner way to do the conditional statements, but this way worked for me.
(As a bonus, is there an easy way to avoid the repeated "-o $i =" in the
script below?)

******************************
************************************************************
for ((  i = 1;  i <= 86;  i++  ))
do
 /home/rancid/bin/clogin -x /home/rancid/cmds.txt 10.0.0.$i
if [ $i = 6 -o $i = 12 -o $i = 13 -o $i = 14 -o $i = 16 -o $i = 19 -o $i =
23 -o
 $i = 27 -o $i = 30 -o $i = 32 -o $i = 37 -o $i = 44 -o $i = 45 -o $i = 46
-o $i
 = 48 -o $i = 49 -o $i = 52 -o $i = 53 -o $i = 55 -o $i = 56 -o $i = 57 -o
$i =
58 -o $i = 59 -o $i = 60 -o $i = 61 -o $i = 64 -o $i = 65 -o $i = 70 -o $i =
71
-o $i = 81 -o $i = 72 -o $i = 73 -o $i = 77 -o $i = 82 -o $i = 83 -o $i = 84
-o
$i = 85 -o $i = 86 ]; then
 /home/rancid/bin/clogin -x /home/rancid/cmds.txt 10.0.1.$i
fi
if [ $i = 6 -o $i = 12 -o $i = 14 -o $i = 23 -o $i = 37 -o $i = 44 -o $i =
45 -o
 $i = 52 -o $i = 53 -o $i = 57 -o $i = 61 -o $i = 64 -o $i = 72 -o $i = 73
-o $i
 = 77 -o $i = 83 -o $i = 86 ]; then
 /home/rancid/bin/clogin -x /home/rancid/cmds.txt 10.0.2.$i
fi
if [ $i = 6 -o $i = 12 -o $i = 37 -o $i = 53 -o $i = 57 -o $i = 61 -o $i=64
]; t
hen
 /home/rancid/bin/clogin -x /home/rancid/cmds.txt 10.0.3.$i
fi
done

*******************************************************************************************************8

good luck with it!


On 10/15/07, Munroe, James (DSS/MAS) <James.Munroe at gnb.ca> wrote:
>
> Hello,
>
> Could someone please tell me if there is a way to add a variable to a
> command file for processing with nlogin?  For example I want to issue the
> following command on 170 simliar devices:  "get event > tftp 192.168.1.1<ROUTERNAME>.log"  The <ROUTERNAME> needs to be unique for each device.  I
> don't care if it's the device's IP or hostname or whatever...as long as it
> is unique.  Hostname or IP would be nice though :-)
>
> Also when using nlogin or clogin what's the easiest way to specify a large
> number of remote devices?  I've got like 380+ firewalls and routers that I'd
> like to issue a nlogin/clogin against.  I know the command line gives you
> the option to list each deviceon the same command line...but I was looking
> for something a little more manageable.  I'd eventually like to automate
> this...or script it.
>
> Any help or tips would be greatly appreciated!!!
>
> Thanks!
>
> Jim
> _______________________________________________
> Rancid-discuss mailing list
> Rancid-discuss at shrubbery.net
> http://www.shrubbery.net/mailman/listinfo.cgi/rancid-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.shrubbery.net/pipermail/rancid-discuss/attachments/20071015/afa02e8e/attachment.html 


More information about the Rancid-discuss mailing list