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

Allen Tsang atsang at advance.net
Mon Oct 15 19:05:38 UTC 2007


zomg lulz! holy moly i-can-see-forever-levels of phail, this reminds me 
of the hijinks that the eventual biz-tech refugees pulled on a daily 
basis in CS111 ^^;;;;

Sorry, I'm being mean.... please do a 'man router.db'.  most of the 
answers to your questions lie there; you specify plenty of conditions 
for your routers and will get a nice filtered amount of logging 
information via email.  it's the whole point of rancid!

OTOH, I see that you're just surfing on the back of the expect script to 
run a custom command.... I'll tell you how, but holy moly please learn 
to properly write proper bash scripts!!!... (e.g. use a real list, dude, 
that's the most ugly if statement I've seen in years and years and years):

LIST="6 12 14 16 19 23"
for element in $LIST do
     LOGGING=10.0.0.$element
     clogin -x /home/rancid/cmds.txt 10.0.0.$element
done

Use the "LOGGING" environmental variable in your custom clogin script to 
output wherever you want your output to be.

repeat if you so desire, for ips in other ranges.  And please learn to 
script properly! :D

- allen tsang


Chris Stave wrote:
> I've made a script to call clogin, our devices are numbered fairly 
> sequentially, from 10.0.0.1 <http://10.0.0.1/> to 10.0.0.86 
> <http://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 
> <mailto: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 <http://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 <mailto:Rancid-discuss at shrubbery.net>
>     http://www.shrubbery.net/mailman/listinfo.cgi/rancid-discuss
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Rancid-discuss mailing list
> Rancid-discuss at shrubbery.net
> http://www.shrubbery.net/mailman/listinfo.cgi/rancid-discuss



More information about the Rancid-discuss mailing list