Mailing List Archive

Clogin Options
All--

I'm a big fan of the "clogin" script. I would like to use this script
to be able to send configuration changes to many routers on my network.
I understand how to make the script reference another file for the
commands, but I don't see an option to reference a file for a list of
routers. Is there a way to do this? It would be much easier than
listing out all the devices with semi-colons.

Steve
Clogin Options [ In reply to ]
Fri, Sep 23, 2005 at 01:25:25PM -0400, Pierce, Steven T (Steve), CMO:
> All--
>
> I'm a big fan of the "clogin" script. I would like to use this script
> to be able to send configuration changes to many routers on my network.
> I understand how to make the script reference another file for the
> commands, but I don't see an option to reference a file for a list of
> routers. Is there a way to do this? It would be much easier than
> listing out all the devices with semi-colons.
>
> Steve
>

clogin -s script rtr1 rtr2 rtr3 ...

or
clogin -s script `cat routerlist`

or
cat routerlist | xargs clogin -s script
Clogin Options [ In reply to ]
I often use this sort of thing:

#!/usr/bin/perl -w

my @routers;
my $clogin = "/usr/local/rancid2/bin/clogin";
my $clogin_cmd = "-c conf t\nconfig line blah\nconfig line 2 blah\nexit\nwrite\n\n";

open ROUTERDB, "/usr/local/rancid2/group_name/router.db" or
die "Can't open router.db: $!";
while (<ROUTERDB>) {
if ( /\:down$/ ) { next; }
s/\:.*$//;
push @routers, ($_);
}

for my $router (@routers) {
chomp $router;
print "===$router===\n";
system ( "$clogin", "$clogin_cmd", "$router" );
}

For more complicated configs, I use clogin to just tell the router to do
a copy tftp: run; write; and I put the config in a tftp server
accessible file.

--Stafford
Clogin Options [ In reply to ]
you could stir in par(1) and do that in parallel.

Fri, Sep 23, 2005 at 11:22:15AM -0700, Stafford A. Rau:
> I often use this sort of thing:
>
> #!/usr/bin/perl -w
>
> my @routers;
> my $clogin = "/usr/local/rancid2/bin/clogin";
> my $clogin_cmd = "-c conf t\nconfig line blah\nconfig line 2 blah\nexit\nwrite\n\n";
>
> open ROUTERDB, "/usr/local/rancid2/group_name/router.db" or
> die "Can't open router.db: $!";
> while (<ROUTERDB>) {
> if ( /\:down$/ ) { next; }
> s/\:.*$//;
> push @routers, ($_);
> }
>
> for my $router (@routers) {
> chomp $router;
> print "===$router===\n";
> system ( "$clogin", "$clogin_cmd", "$router" );
> }
>
> For more complicated configs, I use clogin to just tell the router to do
> a copy tftp: run; write; and I put the config in a tftp server
> accessible file.
>
> --Stafford
Clogin Options [ In reply to ]
--On Friday, September 23, 2005 10:29 AM -0700 john heasley
<heas at shrubbery.net> wrote:

> Fri, Sep 23, 2005 at 01:25:25PM -0400, Pierce, Steven T (Steve), CMO:
>> All--
>>
>> I'm a big fan of the "clogin" script. I would like to use this script
>> to be able to send configuration changes to many routers on my network.
>> I understand how to make the script reference another file for the
>> commands, but I don't see an option to reference a file for a list of
>> routers. Is there a way to do this? It would be much easier than
>> listing out all the devices with semi-colons.
>>
>> Steve
>>
>
> clogin -s script rtr1 rtr2 rtr3 ...
>
> or
> clogin -s script `cat routerlist`
>
> or
> cat routerlist | xargs clogin -s script

You can also do the routers in parallel with par.
Clogin Options [ In reply to ]
> You can also do the routers in parallel with par.

how about something at the opposite end of the spectrum, stop
as soon as anything fails?

randy
Clogin Options [ In reply to ]
Fri, Sep 23, 2005 at 04:48:48PM -1000, Randy Bush:
> > You can also do the routers in parallel with par.
>
> how about something at the opposite end of the spectrum, stop
> as soon as anything fails?
>
> randy

unfortunately the login scripts all exit 0, assuming they get to the
point of logging into the device. yes, that needs to be fixed. but,
you can wrap it;

clogin device |& grep -v Error:
exit $?