From: Cho, David (David.Cho@xmradio.com)
Date: Fri Dec 12 2003 - 11:01:01 GMT-3
Nickolay,
You need the "prompt" variable to push to Telnet:Cisco's stack in order to
support devices like CSS and others. Telnet:Cisco has typical host names
programmed but not all. Hence, you need to educate the Telnet:Cisco with
prompt parameter. HTH, David
-----Original Message-----
From: Nickolay Romensky [mailto:nromensky@merc-int.com]
Sent: Thursday, December 11, 2003 9:30 PM
To: security@groupstudy.com; ccielab@groupstudy.com
Subject: RE: Backing up config
Here it is. It takes data (IP, passwords, what-to-do) from external file.
It's not the simplest one
--cut--
#!/bin/perl
# Written by Nickolay Romensky, Mercury Interactive
use Net::Telnet::Cisco;
use strict;
my($password);
my($shell) = new Net::Telnet::Cisco;
my(@output);
my(@line);
my($date) = `date +%Y.%m.%d.%H%M%S`; chomp($date);
my($base) = '/usr/local/get-config';
my($configs) = "$base/configs";
open(LIST,"$base/get-config-list") or die("Cannot open file
$base/get-config-list");
while(<LIST>) {
chomp;
# tr/ //d;
if ($_ eq '') { next;}
if (substr($_,0,1) eq "#") { next; }
@line = split(':');
if ($shell = Net::Telnet::Cisco->new(Host => $line[0],Input_log =>
'input_log', Dump_log => 'dump_log' )) {
print "Login to $line[0]\n";
if ($line[1] eq '') { $shell -> login(Password => $line[2]); } else
{ $shell -> login($line[1],$line[2]); }
if ($line[3] ne '') {
print " Enable $line[0]\n";
if (!($shell -> enable($line[3]))) { warn "Can't enable $_ : " .
$shell->errmsg; }
}
if ($line[4] ne '') { print " Start $line[4]\n"; $shell ->
cmd($line[4]); }
$shell -> cmd( 'terminal length 0' );
if ($line[5] ne '') {
print " Start $line[5]\n";
@output = $shell -> cmd(String => $line[5], Timeout => 60);
foreach(@output) { chomp;`echo '$_' >>
$configs/$line[0]-$date.config.temp`; }
`/bin/unix2dos $configs/$line[0]-$date.config.temp
$configs/$line[0]-$date.config 2> /dev/null`;
`/bin/zip $configs/$line[0]-$date.config.zip
$configs/$line[0]-$date.config`;
`rm -f $configs/$line[0]-$date.config`;
`rm -f $configs/*.temp`;
}
} else { warn "Can't login $_ : " . $shell->errmsg; }
print " $line[0] done\n";
}
close(LIST);
# remove old files (60 days and older)
my($tmp) = "find $configs -mtime +60 -type f -exec rm -rf {} \\;"; `$tmp`;
--cut--
-----Original Message-----
From: JHays [mailto:nomad@gfoyle.org]
Sent: Thursday, December 11, 2003 5:54 AM
To: 'Nickolay Romensky'; security@groupstudy.com; ccielab@groupstudy.com
Subject: RE: Backing up config
Would you please post your Perl script? I for one would be interested.
Thanks
-----Original Message-----
From: nobody@groupstudy.com [mailto:nobody@groupstudy.com] On Behalf Of
Nickolay Romensky
Sent: Wednesday, December 10, 2003 11:05 PM
To: security@groupstudy.com; ccielab@groupstudy.com
Subject: Backing up config
I use simple Perl script (with Telnet:Cisco module) to backup routers and
switches configs every day. It works pretty well for a long time.
Some devices does not supported by Telnet:Cisco, CSS is one of them (from
what I've seen). Also it works with telnet only (no ssh).
Are there any freeware tools (Unix based preferably) fix these limitations?
Maybe new interesting Perl modules?
I know about Cisco Works abilities... Don't like CW as a product...
Thanks,
Nickolay
This archive was generated by hypermail 2.1.4 : Sat Jan 03 2004 - 08:25:39 GMT-3