blib/lib/Net/Telnet/Cisco/IOS.pm untested

filter: Statementstmt 0.0% 0 / 375 Branchbran 0.0% 0 / 126 Conditioncond 0.0% 0 / 19 MC/DCmcdc 0.0% 0 / 12 Subroutinesub 0.0% 0 / 36 Podpod 0.0% 0 / 33 totaltotal 0.0% 0 / 601 CC 64 SCAR 34.6
CC
64
Cov
0%
harmonizeInts
156.0
listInts
30.0
listVLANs
30.0
CRAP 31.7
1 #!#/usr/bin/perl
2 #
3 # TODO:
4 # See sourceforge.net's task list
5 #
6 #
7 #####
8 #
9 # Package Net::Telnet::Cisco::IOS
10 #
11 # Written by Aaron Conaway
12 #
13 # This package extends the Net::Telnet::Cisco package written by
14 # Joshua Keroes. Go go http://nettelnetcisco.sourceforge.net/ for
15 # details on that package.
16 #
17 # The IOS package is for use on Cisco IOS devices. It will not work on
18 # CatOS or any other Cisco OSes.
19 #
20 # I am not a programmer. I merely developed this package out of
21 # necessity to help automate monitoring and configuration of Cisco
22 # devices at work. The code is undoubtedly inefficient and there
23 # are probably 84928 better ways to do what I'm trying to do.
24 #
25 # See the documentation at http://ntci.sourceforge.net.
26 #
27 #####
28 package Net::Telnet::Cisco::IOS;
29  
30 use Net::Telnet::Cisco;
31 use strict;
32 use vars qw($AUTOLOAD @ISA $VERSION $DEBUG);
33 # Declare ourselves a child of Net::Telnet::Cisco
34 @ISA = qw(Net::Telnet::Cisco);
35 # Keep the version number
36 $VERSION = "0.6beta";
37  
38 # Constructor
39 sub new {
40 # Get my own class type
41 my $class = shift;
42 my ($self, $host, %args);
43
44 # Call the super constructor
45 $self = $class->SUPER::new(@_) or return;
46
47 our ( $platform, $model, $iosver, @config );
48 return $self;
49 }
50  
51 sub login {
52 my $self = shift;
53 $self->SUPER::login(@_) or return;
54 $self->cmd("terminal length 0");
55 return;
56 }
57  
58 # Returns the version number
59 sub getModVer {
60 return $VERSION;
61 }
62  
63 # Returns IOS version of router
64 # Priv 1
65 sub getIOSVer {
66 my $cmd = "show version";
67 my $self = shift;
68 # Try to run the command
69 my @result = $self->cmd( $cmd );
70  
71 foreach my $line ( @result ) {
72 if ( $line =~ /, Version (.+),/ ) {
73 return $1;
74 }
75 }
76 return 0;
77 }
78  
79  
80 # Returns hash of 5-sec, 1-min, and 5-minute CPU averages
81 # Priv 1
82 sub getCPU {
83 # cmd is what command we send to the IOS device
84 my $cmd = "show process cpu";
85 # Initialize the hash
86 my %ret = ( "5sec" => "na",
87 "1min" => "na",
88 "5min" => "na"
89 );
90 # Set the object up
91 my $self = shift;
92 # Try to run the command
93 my @result = $self->cmd( $cmd );
94  
95 foreach my $line ( @result ) {
96 if ( $line =~ /five seconds: (.+)\/.+; one minute: (.+); five minutes: (.+)/ ) {
97 $ret{ "5sec" } = $1;
98 $ret{ "1min" } = $2;
99 $ret{ "5min" } = $3;
100 }
101 }
102 return %ret;
103 }
104
105 # Returns all the ints in an array
106 # Priv 1
107 sub listInts {
108 my $self = shift;
109 my @ret;
110 my $int;
111 my $cmd = "sh ip interface brief";
112 my @result = $self->cmd( $cmd );
113  
114 foreach my $line ( @result ) {
115 if ( $line =~ /^Interface/i ) { }
116 elsif ( $line =~ /^-----/ ) { }
117 elsif ( $line =~ /^\s/ ) { }
118 elsif ( $line =~ /^\W/ ) { }
119 else {
120 my $int = substr( $line, 0, 23 );
121 $int =~ s/\s+$//g;
122 push ( @ret, $int );
123 }
124 }
125 return @ret;
126 }
127  
128 # Priv 1
129 sub listVLANs {
130 my $self = shift;
131 my @ret;
132 my $cmd = "show vlan brief";
133 my ( $vlanid, $vlanname );
134 my @result = $self->cmd( $cmd );
135  
136 # Go through each line of the command result
137 foreach my $line ( @result ) {
138 # If it starts with "Port", do nothing
139 if ( $line =~ /^VLAN/i ) { }
140 # If it starts with "----", do nothing
141 elsif ( $line =~ /^----/ ) { }
142 # If it starts with whitespace, do nothing
143 elsif ( $line =~ /^\s+/ ) { }
144 else {
145 # Get the first two columns
146 $vlanid = substr( $line, 0, 4);
147 $vlanname = substr ( $line, 5, 30 );
148 if ( $vlanid =~ /100[2-5]/ ) { }
149 else {
150 $vlanid =~ s/\s+$//g;
151 # Put the line onto the end of the return array
152 push ( @ret, $vlanid );
153 }
154 }
155 }
156 # Return the return array
157 return @ret;
158 }
159  
160 # Priv 1
161 sub getIntState {
162 my ( $self, @args ) = @_;
163 my %result;
164 my $if = &harmonizeInts( $args[0] );
165 my $cmd = "sh interface " . $if;
166 my @output = $self->cmd( $cmd );
167  
168 foreach my $line ( @output ) {
169 if ( $line =~ /$if is (.+), line protocol is (.+) / ) {
170 $result{'port'} = $1;
171 $result{'lineprotocol'} = $2;
172 } else { }
173 }
174 return %result;
175 }
176  
177 # Priv 1
178 sub getIntDesc {
179 my ( $self, @args ) = @_;
180 my $if = &harmonizeInts( $args[0] );
181 my $cmd = "sh interface " . $if;
182 my @result = $self->cmd( $cmd );
183  
184 foreach my $line ( @result ) {
185 if ( $line =~ /Description: (.+)/ ) {
186 return $1;
187 } else { }
188 }
189 return 0;
190 }
191  
192 # Priv 1
193 sub getEthSpeed {
194 my ( $self, @args ) = @_;
195 my $if = &harmonizeInts( $args[0] );
196 my $cmd = "sh interface " . $if;
197 my @result = $self->cmd( $cmd );
198  
199 foreach my $line ( @result ) {
200 if ( $line =~ /Auto Speed \((.+)\),/ ) {
201 return $1;
202 } elsif ( $line =~ /, (.+)Mb\/s/ ) {
203 return $1;
204 }
205 }
206 return 0;
207 }
208  
209 # Priv 1
210 sub getEthDuplex {
211 my ( $self, @args ) = @_;
212 my $if = &harmonizeInts( $args[0] );
213 my $cmd = "sh interface " . $if;
214 my @result = $self->cmd( $cmd );
215  
216 foreach my $line ( @result ) {
217 if ( $line =~ /\s+Auto-duplex \((.{4})\),/ ) {
218 return $1;
219 } elsif ( $line =~ /\s+(.+)-duplex/ ) {
220 if ( $1 eq "Auto" ) { }
221 else {
222 return $1;
223 }
224 }
225 }
226 return 0;
227 }
228  
229 # Priv 1
230 sub getIntBandwidth {
231 my ( $self, @args ) = @_;
232 my $if = &harmonizeInts( $args[0] );
233 my $cmd = "sh interface " . $if;
234 my @result = $self->cmd( $cmd );
235  
236 foreach my $line ( @result ) {
237 if ( $line =~ /\s+BW (.+) Kbit/ ) {
238 return $1;
239 } else { }
240 }
241  
242 }
243  
244  
245 # Priv 1
246 sub getIntInputRate {
247 my ( $self, @args ) = @_;
248 my $if = &harmonizeInts( $args[0] );
249 my $cmd = "sh interface " . $if;
250 my @result = $self->cmd( $cmd );
251  
252 foreach my $line ( @result ) {
253 if ( $line =~ /5 minute input rate (.+) bits/ ) {
254 return $1;
255 } else { }
256 }
257
258 }
259  
260 # Priv 1
261 sub getIntInputErrors {
262 my ( $self, @args ) = @_;
263 my $if = &harmonizeInts( $args[0] );
264 my $cmd = "sh interface " . $if;
265 my @result = $self->cmd( $cmd );
266  
267 foreach my $line ( @result ) {
268 if ( $line =~ /(.+) input errors,/ ) {
269 return $1;
270 } else { }
271 }
272 return 0;
273  
274 }
275  
276 # Priv 1
277 sub getIntOutputRate {
278 my ( $self, @args ) = @_;
279 my $if = &harmonizeInts( $args[0] );
280 my $cmd = "sh interface " . $if;
281 my @result = $self->cmd( $cmd );
282  
283 foreach my $line ( @result ) {
284 if ( $line =~ /5 minute output rate (.+) bits/ ) {
285 return $1;
286 } else { }
287 }
288  
289 }
290  
291 # Priv 1
292 sub getIntOutputErrors {
293 my ( $self, @args ) = @_;
294 my $if = &harmonizeInts( $args[0] );
295 my $cmd = "sh interface " . $if;
296 my @result = $self->cmd( $cmd );
297  
298 foreach my $line ( @result ) {
299 if ( $line =~ /(.+) output errors,/ ) {
300 return $1;
301 } else { }
302 }
303 return 0;
304 }
305  
306 # Priv 1
307 sub findVLAN {
308 my ( $self, @args ) = @_;
309 my $if = &harmonizeInts( $args[0] );
310 my $cmd = "sh interface " . $if . " status";
311 my @result = $self->cmd( $cmd );
312 my $vlan = undef;
313  
314 foreach my $line ( @result ) {
315 if ( $line =~ /^Port/ ) { }
316 elsif ( $line =~ /^-----/ ) { }
317 elsif ( $line =~ /^\s+/ ) { }
318 else {
319 $vlan = substr( $line, 40, 8 );
320 $vlan =~ s/\s+//g;
321 return $vlan;
322 }
323 }
324 return $vlan;
325 }
326  
327 # Priv 15
328 sub getConfig {
329 my $self = shift;
330 my $cmd = "show running-config";
331 my @result = $self->cmd( $cmd );
332  
333 return @result;
334 }
335  
336 # Priv 1
337 sub getModel {
338 my $self = shift;
339 my $cmd = "sh ver";
340 my $plat;
341 my @result = $self->cmd( $cmd );
342  
343 foreach my $line ( @result ) {
344 if ( $line =~ /^IOS \(tm\) (.+) Software/ ) {
345 return $1;
346 } elsif ( $line =~ /cisco (.+) processor/ ) {
347 return $1;
348 }
349 }
350 return 0;
351 }
352  
353 # Priv 1
354 sub getPlatform {
355 my ( $self, @args ) = @_;
356 my $platform;
357 my $model = $args[0];
358
359 if ( $model =~ /29.0/ || $model =~ /3750/ ) {
360 return "s";
361 } elsif ( $model =~ /RSP/ || $model =~ /7200/ ) {
362 return "r";
363 }
364 return 0;
365 }
366  
367 # Priv 1
368 sub getIntCAM {
369 my ( $self, @args ) = @_;
370 my $int = harmonizeInts( $args[0] );
371 my $cmd = "show mac-address-table interface " . $int;
372 my @ret;
373 my @output = $self->cmd( $cmd );
374 my $model = $self->getModel();
375  
376 foreach my $line ( @output ) {
377 my $mac;
378 if ( $line =~ /(\w{4}\.\w{4}\.\w{4})/ ) {
379 push ( @ret, $1 );
380 }
381 }
382 return @ret;
383 }
384  
385 # Priv 1
386 sub getIntARP {
387 my ( $self, @args ) = @_;
388 my $int = harmonizeInts( $args[0] );
389 my $cmd = "show arp";
390 my @ret;
391 my @output = $self->cmd( $cmd );
392  
393 foreach my $line ( @output ) {
394 chomp $line;
395 if ( $line =~ /$int/ && $line =~ /(\w{4}\.\w{4}\.\w{4})/ ) {
396 push ( @ret, $1 );
397 }
398 }
399 return @ret;
400 }
401  
402 # Priv 1
403 sub arpLookup {
404 my ( $self, @args ) = @_;
405 my $cmd = "show arp";
406 my @output = $self->cmd( $cmd );
407  
408 foreach my $line ( @output ) {
409 chomp $line;
410 if ( $line =~ /$args[0]/ ) {
411 my $ip = substr ( $line, 10, 15 );
412 if ( length( $ip ) == 0 ) { }
413 else {
414 return $ip;
415 }
416 }
417 }
418 return 0;
419 }
420  
421 # Priv 1
422 sub getACLs {
423 my $self = shift;
424 my $cmd = "show access-lists";
425 my @ret;
426 my @output = $self->cmd( $cmd );
427  
428 foreach my $line ( @output ) {
429 if ( $line =~ /access list (.+)\n/ ) {
430 push ( @ret, $1 );
431 }
432 }
433 return @ret;
434 }
435
436 # Priv 15
437 sub getSNMPComm {
438 my $self = shift;
439 my @ret;
440 my @output = $self->getConfig();
441  
442 foreach my $line ( @output ) {
443 if ( $line =~ /snmp-server community (.+) / ) {
444 push ( @ret, $1 );
445 }
446 }
447 return @ret;
448 }
449  
450 # Priv 1
451 sub privLevel {
452 my $self = shift;
453 my $cmd = "show privilege";
454 my $ret = 0;
455 my @output = $self->cmd( $cmd );
456  
457 foreach my $line ( @output ) {
458 if ( $line =~ /^Current privilege level is (\d{1,2})/ ) {
459 $ret = $1;
460 }
461 }
462 return $ret;
463 }
464
465 # Priv 1
466 sub getVTP {
467 my $self = shift;
468 my $cmd = "show vtp status";
469 my ( $ver, $mode, $domain );
470 my %ret;
471 my @output = $self->cmd( $cmd );
472
473 foreach my $line ( @output ) {
474 if ( $line =~ /^VTP Version\s+: (.)\n/ ) {
475 $ver = $1;
476 }
477 elsif ( $line =~ /^VTP Operating Mode\s+: (.+)\n/ ) {
478 $mode = $1;
479 }
480 elsif ( $line =~ /^VTP Domain Name\s+: (.+)\n/ ) {
481 $domain = $1;
482 }
483 }
484 %ret = (
485 version => $ver,
486 mode => $mode,
487 domain => $domain,
488 );
489 return %ret;
490 }
491  
492 # Priv 1
493 sub getIntACL {
494 my ( $self, @args ) = @_;
495 my $inacl = 0;
496 my $outacl = 0;
497 my $cmd = "show ip int " . $args[0];
498 my @outacl = ("Outgoing access list is ", "Outbound access list is ");
499 my @inacl = ("Inbound access list is ", "Inbound access list is ");
500 my %ret;
501 my @output = $self->cmd( $cmd );
502
503 foreach my $line ( @output ) {
504 ACL:
505 {
506 foreach my $acl ( @outacl ) {
507 if ( $line =~ /$acl(.+)/ ) {
508 $outacl = $1;
509 last ACL;
510 }
511 }
512 foreach my $acl ( @inacl ) {
513 if ( $line =~ /$acl(.+)/ ) {
514 $inacl = $1;
515 last ACL;
516 }
517 }
518 } # ACL
519 }
520
521 if ( $inacl eq "not set" || $inacl eq "" ) {
522 $inacl = 0;
523 }
524 if ( $outacl eq "not set" || $outacl eq "") {
525 $outacl = 0;
526 }
527  
528 %ret = (
529 inbound => $inacl,
530 outbound => $outacl,
531 );
532 return %ret;
533 }
534  
535 # Priv 1
536 sub getIPRoute {
537 my ( $self, @args ) = @_;
538 my %ret = ( route => 0,
539 protocol => 0,
540 nexthop => 0);
541 my $cmd = "show ip route " . $args[0];
542 my @result = $self->cmd( $cmd );
543 foreach my $line ( @result ) {
544 if ( $line =~ /Routing entry for (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\/\d{1,2})/ ) {
545 $ret{'route'} = $1;
546 }
547 if ( $line =~ /Known via \"(.+)\"/ ) {
548 $ret{ 'protocol' } = $1;
549 }
550 if ( $line =~ /directly connected, via (.+)\W/ ) {
551 $ret{ 'nexthop' } = $1;
552 }
553 if ( $line =~ /\* (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/ ) {
554 $ret{ 'nexthop' } = $1;
555 }
556 }
557 return %ret;
558 }
559  
560 # Priv 15
561 sub getNTP {
562 my $self = shift;
563 my %ret;
564 my ( $server, $source, $mode );
565  
566 my @result = $self->getConfig();
567 foreach my $line ( @result ) {
568 if ( $line =~ /^ntp server (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) source (\w+) (\w+)/ ) {
569 $server = $1;
570 $source = harmonizeInts( $2 );
571 $mode = $3;
572 }
573 elsif ( $line =~ /^ntp server (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) prefer/ ) {
574 $server = $1;
575 $mode = "prefer";
576 }
577 elsif ( $line =~ /^ntp source (.+)$/ ) {
578 $source = harmonizeInts( $1 );
579 }
580 }
581 %ret = ( server => $server,
582 source => $source,
583 mode => $mode );
584 return %ret;
585 }
586 # Priv 15
587 sub disableInt {
588 # Fix the return codes.
589 my ( $self, @args ) = @_;
590 my $result;
591 my $if = &harmonizeInts( $args[0] );
592 my $cmd = "shutdown";
593 eval {
594 $self->cmd( "configure terminal" );
595 $self->cmd( "interface $if" );
596 $self->cmd( "$cmd" );
597 $self->cmd( "exit\nexit" );
598 };
599 if ( length( $self->errmsg() ) > 0 ) {
600 return 0;
601 }
602 return 1;
603 }
604  
605 # Priv 15
606 sub saveConfig {
607 my $self = shift;
608 my $cmd = "write memory";
609 if ( !$self->cmd( $cmd ) ) {
610 print "Couldn't do it";
611 <STDIN>;
612 return 0;
613 }
614 return 1;
615 }
616  
617 sub harmonizeInts {
618 my $input = shift;
619 my @FastEthernet = qw(FastEthernet FastEth Fast FE Fa F);
620 my @GigEthernet = qw(GigabitEthernet GigEthernet GigEth GE Gi G);
621 my @Ethernet = qw(Ethernet Eth E);
622 my @Serial = qw(Serial Se S);
623 my @PortChannel = qw(PortChannel Port-Channel Po);
624 my @POS = qw(POS P);
625 my @VLAN = qw(VLAN VL V);
626 my @LOOPBACK = qw(Loopback Loop Lo);
627 my @ATM = qw(ATM AT A);
628 my @DIALER = qw(Dialer Dial Di D);
629 my @VIRTUALACCESS = qw(Virtual-Access Virtual-A Virtual Virt);
630 IFS:
631 {
632 # Go through the array @FastEthernet
633 foreach my $fe ( @FastEthernet )
634 {
635 # If the user's input matches
636 if ( $input =~ /^$fe\d/i )
637 {
638 # Take the number part out
639 $input =~ /^$fe(.+)\b/i;
640 # Reset $val to the long name + number
641 $input = "FastEthernet" . $1;
642 # Leave the block because we found it
643 last IFS;
644 }
645 }
646 # Go through the array @GigEthernet
647 foreach my $ge ( @GigEthernet )
648 {
649 # If the user's input matches
650 if ( $input =~ /^$ge\d/i )
651 {
652 # Take the number part out
653 $input =~ /^$ge(.+)\b/i;
654 # Reset $val to the long name + number
655 $input = "GigabitEthernet" . $1;
656 # Leave the block because we found it
657 last IFS;
658 }
659 }
660 # Go through the array @Ethernet
661 foreach my $e ( @Ethernet )
662 {
663 # If the user's input matches
664 if ( $input =~ /^$e\d/i )
665 {
666 # Take the number part out
667 $input =~ /^$e(.+)\b/i;
668 # Reset $val to the long name + number
669 $input = "Ethernet" . $1;
670 # Leave the block because we found it
671 last IFS;
672 }
673 }
674 # Go through the array @Serial
675 foreach my $s ( @Serial )
676 {
677 # If the user's input matches
678 if ( $input =~ /^$s\d/i )
679 {
680 # Take the number part out
681 $input =~ /^$s(.+)\b/i;
682 # Reset $val to the long name + number
683 $input = "Serial" . $1;
684 # Leave the block because we found it
685 last IFS;
686 }
687 }
688 # Go through the array @PortChannel
689 foreach my $po ( @PortChannel )
690 {
691 # If the user's input matches
692 if ( $input =~ /^$po\d/i )
693 {
694 # Take the number part out
695 $input =~ /^$po(.+)\b/i;
696 # Reset $val to the long name + number
697 $input = "Port-channel" . $1;
698 # Leave the block because we found it
699 last IFS;
700 }
701 }
702 # Go through the array @POS
703 foreach my $pos ( @POS )
704 {
705 # If the user's input matches
706 if ( $input =~ /^$pos\d/i )
707 {
708 # Take the number part out
709 $input =~ /^$pos(.+)\b/i;
710 # Reset $val to the long name + number
711 $input = "POS" . $1;
712 # Leave the block because we found it
713 last IFS;
714 }
715 }
716 # Go through the array @VLAN
717 foreach my $vlan ( @VLAN )
718 {
719 # If the user's input matches
720 if ( $input =~ /^$vlan\d/i )
721 {
722 # Take the number part out
723 $input =~ /^$vlan(.+)\b/i;
724 # Reset $val to the long name + number
725 $input = "VLAN" . $1;
726 # Leave the block because we found it
727 last IFS;
728 }
729 }
730 # Go through the array @LOOPBACK
731 foreach my $lb ( @LOOPBACK )
732 {
733 # If the user's input matches
734 if ( $input =~ /^$lb\d/i )
735 {
736 # Take the number part out
737 $input =~ /^$lb(.+)\b/i;
738 # Reset $val to the long name + number
739 $input = "Loopback" . $1;
740 # Leave the block because we found it
741 last IFS;
742 }
743 }
744 # Go through the array @ATM
745 foreach my $atm ( @ATM )
746 {
747 # If the user's input matches
748 if ( $input =~ /^$atm\d/i )
749 {
750 # Take the number part out
751 $input =~ /^$atm(.+)\b/i;
752 # Reset $val to the long name + number
753 $input = "ATM" . $1;
754 # Leave the block because we found it
755 last IFS;
756 }
757 }
758 # Go through the array @DIALER
759 foreach my $dialer ( @DIALER )
760 {
761 # If the user's input matches
762 if ( $input =~ /^$dialer\d/i )
763 {
764 # Take the number part out
765 $input =~ /^$dialer(.+)\b/i;
766 # Reset $val to the long name + number
767 $input = "Dialer" . $1;
768 # Leave the block because we found it
769 last IFS;
770 }
771 }
772 # Go through the array @VIRTUALACCESS
773 foreach my $virt ( @VIRTUALACCESS )
774 {
775 # If the user's input matches
776 if ( $input =~ /^$virt\d/i )
777 {
778 # Take the number part out
779 $input =~ /^$virt(.+)\b/i;
780 # Reset $val to the long name + number
781 $input = "Virtual-Access" . $1;
782 # Leave the block because we found it
783 last IFS;
784 }
785 }
786 # Since we didn't find it, set $input to 0
787 return 0;
788 } # IFS
789 $input =~ s/\s+//g;
790 return $input;
791 }
792  
793 1;
794 =head1 NAME
795
796 Net::Telnet::Cisco::IOS -- Manage Cisco IOS Devices
797
798 =head1 DESCRIPTION
799
800 Net::Telnet::Cisco::IOS (NTCI) is an extension of Joshua Kereos's Net::Telnet::Cisco module and provides an easy way to manage and monitor Cisco IOS devices. I'll mention this a lot, but make sure you read up on Net::Telnet::Cisco for a lot of information.
801
802 =head1 WHEN TO USE NTCI
803
804 NTCI can do a lot, but it's not the best way to do all of it. I'd suggest you take a look at some SNMP solutions. It's up to you to figure out when and where you want to use it, but don't say I didn't warn you. :)
805
806 =head1 METHODS
807
808 There are way too many methods to list here, so head over to http://ntci.sourceforge.net for a full list with documentation.
809
810 =head1 SYNOPSIS
811
812 use Net::Telnet::Cisco:IOS;
813
814 # Connect and login
815 $connection = Net::Telnet::Cisco::IOS->new( Host => 'hostname');
816 $connection->login( Name => 'username', Password => 'password' );
817
818 # Get the IOS version
819 if ( $ver = $connection->getIOSVer() ) {
820 print "The device is running version " . $ver . "\n";
821 }
822 else {
823 print "Can't get the version:\n";
824 print $connection->errmsg();
825 }
826
827 # Close the connection
828 $connection->close();
829
830 =head1 MORE INFO
831
832 For more information, examples, and some tips, turn your browser to http://ntci.sourceforge.net.
833
834 =head1 AUTHOR
835
836 NTCI is written by Aaron Conaway. He can be reached at aaron at aconaway period com.
837
838 =head1 COPYRIGHT AND LICENSE
839
840 (c) 2005 by Aaron Conaway.
841
842 NTCI is distributed under the GPL and may be used by anyone without changes.