ericj has asked for the wisdom of the Perl Monks concerning the following question:

I am using Net::Telnet::Cisco to get itno the routers in Cisco 6000 chassis running hybrid. This works fine and I can do everything I want in the routers. However, I would like to change the script to enter through the switch and then session into the routers. This will allow me to get more information on the layer 3 interfaces. The problem is that I cannot enter the switch. if I have the wrong pass word it tells me that, but when I have the correct password it gives me the following message:
"Use of uninitialized value in pattern match (m//) at /usr/local/lib/perl5/site_perl/5.6.1/Net/Telnet/Cisco.pm line 410, <STDIN> line 2."
It then times out when I try to run the next command. Does anyone have any idea of what I am doing wrong?
  • Comment on Net::Telnet::Cisco with the 6000 chassis

Replies are listed 'Best First'.
Re: Net::Telnet::Cisco... 6000 chassis (non-standard prompt, or Show Me Da Code ;^)
by ybiC (Prior) on Dec 14, 2001 at 02:24 UTC
    Only a guess, but is your 6000 supervisor module configured with a non-standard prompt?

    Hard to help without seeing the code, brother ericj.   Would you post a reply to your original question with relevant section of the script?   Oh yeah, and remember to surround the code itself with "<code>" tags.
        cheers,
        Don
        striving toward Perl Adept
        (it's pronounced "why-bick")

Re: Net::Telnet::Cisco with the 6000 chassis
by ericj (Initiate) on Dec 14, 2001 at 20:14 UTC
    here is a sample of teh code I am using to test getting into the switch.
    #!/usr/local/bin/perl -w use Net::Telnet::Cisco; use strict; my $debug = 1; my $IP_Addr = ""; my $switchPassword = ""; my $routerPassword = ""; my $routerEnPassword = ""; my $switchEnPassword = ""; ## Get the IP Address if ($IP_Addr eq "") { print "Enter the IP Address: "; chop($IP_Addr = <STDIN>); system("stty echo"); print "\n"; } ## Get the switchPassword (make it invisible when entering) if ($switchPassword eq "") { print "Enter the switch password: "; system("stty -echo"); chop($switchPassword = <STDIN>); system("stty echo"); print "\n"; } print "\tConnecting to $IP_Addr\n" if ($debug); my $cs = Net::Telnet::Cisco->new(Host => $IP_Addr); my $ok = $cs->login('login', $switchPassword) or die "Error lo +gging in: @{[ $cs->errmsg() ]}\n"; print "Logged into Switch\n" if ($debug); #Turn off paging my @cmd_output = $cs->cmd( 'terminal length 0' ); #Enter enable mode if ($switchEnPassword eq "") { print "Enter the enable password for the switch: "; system("stty -echo"); chop($switchEnPassword = <STDIN>); system("stty echo"); print "\n"; } $ok = $cs->cmd("enable\n$switchEnPassword"); print "entered enable mode\n"; #$i = 0; #$total = 0; my @portInfo = $cs->cmd("sho port status "); print "Here"; my $arrayElement; foreach $arrayElement (@portInfo) { print "$arrayElement\n"; } ## end foreach() $ok = $cs->disable; $ok = $cs->cmd("session 15\n$routerPassword"); $ok = $cs->cmd("enable\n$routerEnPassword"); my @intStuff = $cs->cmd("dir"); foreach $arrayElement (@portInfo) { print "$arrayElement\n"; } ## end foreach() exit;
    The only difference I see between teh prompts of the router, and the prompts of the switch is that with the router prompts "Password:" and the switch prompts "Enter password:"