[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.24 and 1.25

version 1.24, 2007/01/17 19:00:51 version 1.25, 2007/01/17 20:48:46
Line 1 
Line 1 
 package Net::Telnet::Trango;  package Net::Telnet::Trango;
 # $RedRiver: Trango.pm,v 1.23 2007/01/08 22:16:29 mike Exp $  # $RedRiver: Trango.pm,v 1.24 2007/01/17 19:00:51 andrew Exp $
 use strict;  use strict;
 use warnings;  use warnings;
 use base 'Net::Telnet';  use base 'Net::Telnet';
Line 209 
Line 209 
 returns the output from the last cmd() that was run as an array ref  returns the output from the last cmd() that was run as an array ref
 This is usually only set internally  This is usually only set internally
   
   =item last_error
   
   returns the last error reported.  Should contain the the last entry in
   last_lines
   
 =back  =back
   
 =head2 ALIASES  =head2 ALIASES
Line 341 
Line 346 
   Timeout    Timeout
   last_lines    last_lines
   last_vals    last_vals
     last_error
 );  );
   
 sub AUTOLOAD  sub AUTOLOAD
Line 386 
Line 392 
   my $self = shift;    my $self = shift;
   
   unless ( $self->SUPER::open(@_) ) {    unless ( $self->SUPER::open(@_) ) {
     #$! = "Couldn't connect to " . $self->Host . ":  $!";      $self->last_error("Couldn't connect to " . $self->Host . ":  $!");
     return undef;      return undef;
   }    }
   
Line 395 
Line 401 
       -match => '/password: ?$/i',        -match => '/password: ?$/i',
       -errmode => "return",        -errmode => "return",
     ) ) {      ) ) {
     #$! = "problem connecting to host (" . $self->Host . "): " .      $self->last_error("problem connecting to host (" . $self->Host . "): " .
     #    $self->lastline;          $self->lastline);
     return undef;      return undef;
   }    }
   
Line 431 
Line 437 
     -match => $self->prompt,      -match => $self->prompt,
     -errmode => "return",      -errmode => "return",
   ) ) {    ) ) {
     #$! = "login ($self->Host) failed: " . $self->lastline;      $self->last_error("login ($self->Host) failed: " . $self->lastline);
     return undef;      return undef;
   }    }
   
Line 486 
Line 492 
   my $su       = shift || 'all';    my $su       = shift || 'all';
   
   unless (defined $new_pass) {    unless (defined $new_pass) {
     warn "No new password!"      $self->last_error("No new password");
     #return undef;      #return undef;
   }    }
   
Line 515 
Line 521 
         my $new_subnet  = shift;          my $new_subnet  = shift;
         my $new_gateway = shift;          my $new_gateway = shift;
   
         return undef unless $suid =~ /^\d+$/;          if ($suid =~ /\D/) {
         return undef unless $new_ip;                  $self->last_error("Invalid suid '$suid'");
         return undef unless $new_subnet;                  return undef;
         return undef unless $new_gateway;          }
           unless ($new_ip) {
                   $self->last_error("no new_ip passed");
                   return undef;
           }
           unless ($new_subnet) {
                   $self->last_error("no new_subnet passed");
                   return undef;
           }
           unless ($new_gateway) {
                   $self->last_error("no new_gateway passed");
                   return undef;
           }
   
         # su ipconfig <suid> <new ip> <new subnet> <new gateway>          # su ipconfig <suid> <new ip> <new subnet> <new gateway>
         return $self->cmd(String => 'su ipconfig ' .          return $self->cmd(String => 'su ipconfig ' .
Line 607 
Line 625 
         my $mac  = shift;          my $mac  = shift;
   
         if ($suid =~ /\D/) {          if ($suid =~ /\D/) {
                   $self->last_error("Invalid suid '$suid'");
                 return undef;                  return undef;
         }          }
   
         unless (lc($type) eq 'reg' || lc($type) eq 'pr') {          unless (lc($type) eq 'reg' || lc($type) eq 'pr') {
                 warn "Invalid type '$type'!";                  $self->last_error("Invalid type '$type'");
                 return undef;                  return undef;
         }          }
   
         if ($cir =~ /\D/) {          if ($cir =~ /\D/) {
                 warn "Invalid CIR '$cir'!";                  $self->last_error("Invalid CIR '$cir'");
                 return undef;                  return undef;
         }          }
   
         if ($mir =~ /\D/) {          if ($mir =~ /\D/) {
                 warn "Invalid MIR '$mir'!";                  $self->last_error("Invalid MIR '$mir'");
                 return undef;                  return undef;
         }          }
   
         my $new_mac = $mac;          my $new_mac = $mac;
         $new_mac =~ s/[^0-9A-Fa-f]//;          $new_mac =~ s/[^0-9A-Fa-f]//;
         unless (length $new_mac == 12) {          unless (length $new_mac == 12) {
                 warn "Invalid MAC '$mac'!";                  $self->last_error("Invalid MAC '$mac'");
                 return undef;                  return undef;
         }          }
         $new_mac = join ' ', $new_mac =~ /../g;          $new_mac = join ' ', $new_mac =~ /../g;
Line 661 
Line 680 
         my $self = shift;          my $self = shift;
         my $suid = shift;          my $suid = shift;
   
         if (lc($suid) ne 'all' || $suid =~ /\D/) {          #if (lc($suid) ne 'all' || $suid =~ /\D/) {
           if ($suid =~ /\D/) {
                   $self->last_error("Invalid suid '$suid'");
                 return undef;                  return undef;
         }          }
   
Line 693 
Line 714 
         my $value = shift;          my $value = shift;
   
         if ($suid =~ /\D/) {          if ($suid =~ /\D/) {
                   $self->last_error("Invalid suid '$suid'");
                 return undef;                  return undef;
         }          }
   
         if (lc($opt) eq 'cir' or lc($opt) eq 'mir') {          if (lc($opt) eq 'cir' or lc($opt) eq 'mir') {
                 if ($value =~ /\D/) {                  if ($value =~ /\D/) {
                           $self->last_error("Invalid $opt '$value'");
                         return undef;                          return undef;
                 }                  }
         } elsif (lc($opt) eq 'su2su') {          } elsif (lc($opt) eq 'su2su') {
                 if ($value =~ /[^0-9A-Za-f]/) {                  if ($value =~ /[^0-9A-Za-f]/) {
                           $self->last_error("Invalid MAC '$value'");
                         return undef;                          return undef;
                 }                  }
         } else {          } else {
                   $self->last_error("Invalid option '$opt'");
                 return undef;                  return undef;
         }          }
   
Line 812 
Line 837 
   $cfg{'Timeout'} ||= $self->Timeout;    $cfg{'Timeout'} ||= $self->Timeout;
   
   unless ($cfg{'String'}) {    unless ($cfg{'String'}) {
     #$! = "No command passed";      $self->last_error("No command passed");
     #warn "No command passed\n";  
     return undef;      return undef;
   }    }
   
   unless ($self->is_connected) {    unless ($self->is_connected) {
     #$! = "Not connected";      $self->last_error("Not connected");
     #warn "Not connected\n";  
     return undef;      return undef;
   }    }
   
   unless ($self->logged_in) {    unless ($self->logged_in) {
     #$! = "Not logged in";      $self->last_error("Not logged in");
     #warn "Not logged in\n";  
     return undef;      return undef;
   }    }
   
Line 880 
Line 902 
       return @lines;        return @lines;
     }      }
   } else {    } else {
     #$! = "Error with command ($cfg{'string'}): $last";      $self->last_error("Error with command ($cfg{'String'}): $last");
     return undef;      return undef;
   }    }
 }  }

Legend:
Removed from v.1.24  
changed lines
  Added in v.1.25

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