Below is the code.
I need to login into the router if the 1st set of credentials are correct..
if wrong... then it has to check with 2nd set of credentials..
=> if the credentials are correct... then it should continue..
=> if the credentials are wrong(should not check for 2nd time... then it should check with other set of credentials(mentioned in the program..
Could anyone please help ...
use strict;
use warnings;
use Net::Appliance::Session;
my $ios_device_ip = '10.250.249.215';
my $ios_username = 'cisco';
my $ios_password = 'cisco';
my $ios_enable_password = 'cisco';
#my $user2 = 'newcisco';
#my $pass2 = 'newpass';
#my $enablepassnew = 'cisco';
my $running_config_file = "$ENV{HOME}/running_config.txt";
my $session_obj = Net::Appliance::Session->new(
Host => $ios_device_ip,Transport => 'SSH', );
# give verbose output whilst we run this script
$session_obj->input_log(*STDOUT);
# try to login to the ios device, ignoring host check
$session_obj->connect(
Name => $ios_username,
Password => $ios_password,
SHKC => 0
);
# drop in to enable mode
$session_obj->begin_privileged($ios_enable_password);
# get our running config
my @running_config = $session_obj->cmd('show running');
# chop out the extra info top and bottom of the config
@running_config = @running_config[ 2 .. (@running_config -1)];
open(FH, "> $running_config_file")
or die("Cannot open config file : $!");
print FH @running_config;
close FH;
# close down our session
$session_obj->close;
---------- Post updated 04-25-13 at 05:57 AM ---------- Previous update was 04-24-13 at 08:58 AM ----------
Could anyone please help me on this ?
Thanks in advance...
Regards,
J
---------- Post updated at 05:57 AM ---------- Previous update was at 05:57 AM ----------
Could anyone please help me on this ?
Thanks in advance...
Regards,
J