[BACK]Return to Trango.pm CVS log [TXT][DIR] Up to [local] / trango / Net-Telnet-Trango / lib / Net / Telnet

Diff for /trango/Net-Telnet-Trango/lib/Net/Telnet/Trango.pm between version 1.26 and 1.27

version 1.26, 2007/01/17 23:15:13 version 1.27, 2007/01/31 18:53:29
Line 1 
Line 1 
 package Net::Telnet::Trango;  package Net::Telnet::Trango;
 # $RedRiver: Trango.pm,v 1.25 2007/01/17 20:48:46 andrew Exp $  # $RedRiver: Trango.pm,v 1.26 2007/01/17 23:15:13 andrew Exp $
 use strict;  use strict;
 use warnings;  use warnings;
 use base 'Net::Telnet';  use base 'Net::Telnet';
Line 65 
Line 65 
   
 It also takes an optional parameter 'Decode'.  If not defined it  It also takes an optional parameter 'Decode'.  If not defined it
 defaults to 1, if it is set to 0, it will not decode the output and  defaults to 1, if it is set to 0, it will not decode the output and
 instead return an array of the lines that were returned from the  instead return a reference to an array of the lines that were returned
 command.  from the command.
   
 =cut  =cut
   
Line 179 
Line 179 
   
 =over  =over
   
 =item B<Host>  
   
 - returns the name of the host that you are accessing  
   
 =item B<firmware_version>  =item B<firmware_version>
   
 - returns the firmware version  - returns the firmware version
Line 342 
Line 338 
 =cut  =cut
   
   
 my $success = 'Success.';  my $success = 'Success\\.';
 my %COMMANDS = (  my %COMMANDS = (
   tftpd       => { decode => 'all',   expect => $success },    tftpd       => { decode => 'all',   expect => $success },
   ver         => { decode => 'all' },    ver         => { decode => 'all' },
Line 371 
Line 367 
 my %ALIASES = (  my %ALIASES = (
   bye     => 'exit',    bye     => 'exit',
   restart => 'reboot',    restart => 'reboot',
     Host    => 'host',
 );  );
   
 my %ACCESS = map { $_ => 1 } qw(  my %ACCESS = map { $_ => 1 } qw(
   firmware_version    firmware_version
   host_type    host_type
   Host  
   is_connected    is_connected
   logged_in    logged_in
   login_banner    login_banner
Line 431 
Line 427 
   my $self = shift;    my $self = shift;
   
   unless ( $self->SUPER::open(@_) ) {    unless ( $self->SUPER::open(@_) ) {
     $self->last_error("Couldn't connect to " . $self->Host . ":  $!");      $self->last_error("Couldn't connect to " . $self->host . ":  $!");
     return undef;      return undef;
   }    }
   
Line 440 
Line 436 
       -match => '/password: ?$/i',        -match => '/password: ?$/i',
       -errmode => "return",        -errmode => "return",
     ) ) {      ) ) {
     $self->last_error("problem connecting to host (" . $self->Host . "): " .      $self->last_error("problem connecting to host (" . $self->host . "): " .
         $self->lastline);          $self->lastline);
     return undef;      return undef;
   }    }
Line 478 
Line 474 
     -match => $self->prompt,      -match => $self->prompt,
     -errmode => "return",      -errmode => "return",
   ) ) {    ) ) {
     $self->last_error("login ($self->Host) failed: " . $self->lastline);      $self->last_error("login ($self->host) failed: " . $self->lastline);
     return undef;      return undef;
   }    }
   
Line 621 
Line 617 
   return undef unless @lines;    return undef unless @lines;
   
   unless ($PRIVATE{'Decode'}) {    unless ($PRIVATE{'Decode'}) {
     return @lines;      return \@lines;
   }    }
   
   my @sus;    my @sus;
Line 976 
Line 972 
     if ($PRIVATE{'Decode'} && $cfg{'decode'}) {      if ($PRIVATE{'Decode'} && $cfg{'decode'}) {
       return $vals;        return $vals;
     } else {      } else {
       return @lines;        return \@lines;
     }      }
   } else {    } else {
     $self->last_error("Error with command ($cfg{'String'}): $last");      $self->last_error("Error with command ($cfg{'String'}): $last");
Line 994 
Line 990 
   
   my $key = '';    my $key = '';
   my $val = undef;    my $val = undef;
     my @vals;
   my $in_key = 0;    my $in_key = 0;
   my $in_val = 1;    my $in_val = 1;
   
Line 1018 
Line 1015 
           $key =~ s/^\s+//;            $key =~ s/^\s+//;
           $key =~ s/\s+$//;            $key =~ s/\s+$//;
   
           if (defined $val) {            if ($val) {
             $val =~ s/^\s+//;              $val =~ s/^\s+//;
             $val =~ s/\s+$//;              $val =~ s/\s+$//;
           }            }
Line 1030 
Line 1027 
             $key = $new . " " . $key;              $key = $new . " " . $key;
           }            }
   
           $last_key = $key;  
           $conf{$key} = $val;            $conf{$key} = $val;
             $last_key = $key;
           $key = '';            $key = '';
           $val = '';          } elsif ($val) {
         }                          push @vals, $val;
                   }
           $val = '';
   
       } elsif ($c eq ']') {        } elsif ($c eq ']') {
         $in_val = 1;          $in_val = 1;
Line 1050 
Line 1049 
     }      }
   }    }
   
     unless ($key) {
       push @vals, $val;
     }
   
     if (@vals == 1) {
       $val = $vals[0];
     } elsif (@vals) {
       $val= \@vals;
     } else {
       $val = undef;
     }
   
   if (%conf) {    if (%conf) {
       $conf{_pre} = $val if $val;
     return \%conf;      return \%conf;
   } else {    } else {
     return $val;      return $val;

Legend:
Removed from v.1.26  
changed lines
  Added in v.1.27

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>