Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^4: Cisco Telnet

by mvip (Acolyte)
on Aug 21, 2013 at 05:51 UTC ( [id://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.

Replies are listed 'Best First'.
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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1050283]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2024-04-24 20:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found