Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^4: Cisco Telnet

by mvip (Acolyte)
on Aug 21, 2013 at 05:51 UTC ( #1050283=note: print w/ replies, xml ) Need Help??


in reply to Re^3: Cisco Telnet
in thread Cisco Telnet

well no, and i try that eval procedure and it just gave me the error massage that is saying the router is down and can't connect and the script end. I need something that will tel me that and continue. For example if i have 100 routers and the script start from 1 and as he going on 2,3,4,5 ... (lets say that router 10 is down ) when he comes to router 10 to say i can't connect to this router, and to moves on, and that is router 11, 12, 13 ... not to stop and end. For now iv try eval procedure and with sub routines and iv got nothing ... and i need this because i have to set the same config and settings on almost 300 routers and some of them are down some of them are not that ip end etc.


Comment on Re^4: Cisco Telnet
Re^5: Cisco Telnet
by McA (Priest) on Aug 21, 2013 at 07:19 UTC

    Please let me see the code you used the last time.

    McA

      Hi, here is what iv got ...

      use Net::Telnet::Cisco; #use strict; #use warnings; #use diagnostics; #use threads; my %users =("1" => "admin", "2" => "admin", "3" => "admin", "4" => "admin", "5" => "admin", "6" => "none", "7" => "admin", "8" => "admin", "9" => "admin", "10" => "admin", ); my %pwds = ("1" => "admin", "2" => "admin", "3" => "admin", "4" => "admin", "5" => "admin", "6" =>"s0m3th1ng", "7" => "admin", "8" => "admin", # not connected "9" => "admin", "10" => "admin", ); for ( $i = 1; $i<=10; $i++){ $device = "172.16.$i.251"; if ( $users{$i} eq "none" ) { my $curpwd = $pwds{$i}; my $session = Net::Telnet::Cisco->new(Host => "$device", Input_log => "perllogrouter/ro +uter$i.log", ); eval { $session->login(Password => $curpwd);}; if ($@) { print "Error: $@\n"; } else { if ($session->enable("$curpwd")) { # Execute a command @output = $session->cmd ('show running-config | section ho +stname'); print "@output\n"; print " ================================================== +====\n"; } $session->close; } } else { my $session = Net::Telnet::Cisco->new(Host => "$device", Input_log => "perllogrouter/ro +uter$i.log", ); eval {$session->login($users{$i}, $pwds{$i});}; if ($@) { print "Error: $@\n"; } else { # Execute a command @output = $session->cmd ('show running-config | section ho +stname'); print "@output\n"; print " ================================================== +====\n"; } } }

      I have note that if i have bad or wrong password the script continue but if i have Router that is not alive the script not continue it ends there ...

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1050283]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2014-12-21 05:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (103 votes), past polls