[BACK]Return to update_trango.pl CVS log [TXT][DIR] Up to [local] / trango / Net-Telnet-Trango / scripts

Diff for /trango/Net-Telnet-Trango/scripts/update_trango.pl between version 1.11 and 1.22

version 1.11, 2005/12/21 02:03:30 version 1.22, 2007/02/01 17:58:33
Line 1 
Line 1 
 #!/usr/bin/perl  #!/usr/bin/perl
 # $RedRiver: update_trango.pl,v 1.10 2005/12/21 01:17:06 andrew Exp $  # $RedRiver: update_trango.pl,v 1.21 2007/02/01 17:08:44 mike Exp $
 ########################################################################  ########################################################################
 # update_trango.pl *** Updates trango foxes with a new firmware  # update_trango.pl *** Updates trango foxes with a new firmware
 #  #
 # 2005.11.15 #*#*# andrew fresh <andrew@mad-techies.org>  # 2005.11.15 #*#*# andrew fresh <andrew@mad-techies.org>
 ########################################################################  ########################################################################
 use strict;  use strict;
 use warnings;  use warnings;
   
 use Net::TFTP;  use YAML qw/ Dump LoadFile /;
   use Net::TFTP;
 my $config_file = shift || 'update_trango.conf';  use lib '.';
 my $max_tries = 3;  use Net::Telnet::Trango;
   
   my $config_file = shift || 'update_trango.yaml';
   my $max_tries = 3;
 my $l = Mylogger->new( { log_prefix => 'UT' } );  
   
   my $l = Mylogger->new( { log_prefix => 'UT' } );
 $l->sp("Reading config file '$config_file'");  
 my $conf = read_conf($config_file);  
   $l->sp("Reading config file '$config_file'");
 $l->sp("  Hardware Type: $conf->{'type'}");  my $conf = LoadFile($config_file);
 $l->sp("  File Name:     $conf->{'file_name'}");  
 $l->sp("  File Size:     $conf->{'file_size'}");  #$l->sp("  Hardware Type: $conf->{'type'}");
 $l->sp("  File Checksum: $conf->{'file_cksum'}");  #$l->sp("  File Name:     $conf->{'file_name'}");
 $l->sp("  FW Version:    $conf->{'ver'}");  #$l->sp("  File Size:     $conf->{'file_size'}");
 $l->sp("  FW Checksum:   $conf->{'cksum'}");  #$l->sp("  File Checksum: $conf->{'file_cksum'}");
 $l->sp("");  #$l->sp("  FW Version:    $conf->{'ver'}");
   #$l->sp("  FW Checksum:   $conf->{'cksum'}");
   #$l->sp("");
   
   my @foxes = (
   '10.100.1.2',
   '10.100.2.2',
 foreach my $fox (@{ $conf->{'ips'} }) {  '10.100.3.2',
   $l->sp("Updating: $fox");  '10.100.4.2',
   );
   ## Connect and login.  
   my $t = new Trango::Telnet ({  foreach my $fox (@foxes) {
     Host    => $fox,    $l->sp("Checking: $fox");
     Timeout => 5,    my $needs_reboot = 0;
   });  
     ## Connect and login.
   $l->p("Connecting to $fox");    my $t = new Net::Telnet::Trango (
   my ($type, $version) = $t->connect();      Timeout => 5,
       Errmode => 'return',
   unless (defined $type && defined $version) {    ) or die "Couldn't make new connection: $!";
     $l->sp("Error connecting!");    $l->p("Connecting to $fox");
     next;    unless ( $t->open($fox) ) {
   }      $l->sp("Error connecting: $!");
       next;
   if ($type ne $conf->{'type'}) {    }
     $l->sp("Wrong type of unit ('$type' should be '$conf->{'type'}')");  
     $t->close;    foreach my $firmware_type ('Firmware', 'FPGA') {
     next;  
   }      if (! exists $conf->{$firmware_type}) {
             $l->s("No configs for '$firmware_type'");
   if ($version eq $conf->{'ver'}) {            $t->close();
     $l->sp("Already up to date with firmware version '$version'");            next;
     $t->close;          }
     next;  
   }      my $host_type = $t->host_type;
       if (uc($conf->{'firmware_type'}) eq 'FPGA') {
   $l->p("Logging in");        $host_type =~ s/\s.*$//;
   $t->login($conf->{'password'}) || die "Couldn't login: $!";      }
   
   $l->p("Sending commands");      if (! exists $conf->{$firmware_type}->{$host_type}) {
   ## Send commands            $l->sp("No '$firmware_type' config for type $host_type");
   if ( upload($t, $conf->{'file_name'}) ) {            $t->close();
     $l->p("Rebooting");            next;
     $t->reboot;          }
   } else {  
     $l->p("Exiting");      unless ($t->logged_in) {
     $t->exit;        $l->p("Logging in");
   }        $t->login($conf->{general}->{'password'}) || die "Couldn't login: $!";
   $t->close;            $t->exit();
   $l->sp("");      }
 }  
           foreach my $k (keys %{ $conf->{general} }) {
 sub upload            $conf->{$firmware_type}->{$host_type}->{$k} ||= $conf->{general}->{$k};
 {      }
   my $t    = shift;          $conf->{$firmware_type}->{$host_type}->{firmware_type} ||= $firmware_type;
   my $file = shift;          $conf->{$firmware_type}->{$host_type}->{type} ||= $host_type;
   
   my $ver = $t->ver;      $l->sp("Updating: $host_type $firmware_type on $fox");
   $l->p("Current version '$ver->{'Firmware Version'}'");      $l->p("Sending commands");
       ## Send commands
   if (      if ( upload($t, $conf->{$firmware_type}->{$host_type}) ) {
     $ver->{'Firmware Version'}  eq $conf->{'ver'} &&        $l->sp("Successfull!");
     $ver->{'Firmware Checksum'} eq $conf->{'cksum'}            $needs_reboot = 1;
   ) {      } else {
     $l->sp("Already updated!");            $l->sp("Failed");
     return 1;      }
   }  
       $l->sp("");
   my $try = 0;    }
   while (1) {  
     if ($try >= $max_tries) {    if ($needs_reboot) {
       $l->sp("Couldn't update in $max_tries tries!");      $l->sp("Rebooting $fox");
       return undef;      $t->reboot;
     }    } else {
     $try++;      $l->sp("Exiting $fox");
       $t->exit();
     #sysinfo($self->{'_host'});    }
         exit;
     $l->p("Enabling TFTPd");  }
     $t->enable_tftpd || die "Couldn't enable tftpd";  
   sub upload
     $l->p("Uploading file ($file)");  {
     # use tftp to push the file up    my $t    = shift;
     my $tftp = Net::TFTP->new($t->Host, Mode => 'octet');    my $conf = shift;
   
     $tftp->put($file, $file)    my $file = $conf->{firmware_path} . '/' . $conf->{file_name};
       or die "Error uploading: " . $tftp->error;  
     my $fw_type = $conf->{firmware_type};
     # waitfor some sort of output  
     # make sure it says 'Success.' otherwise error    my $ver = $t->ver;
     #print "LAST: " . $self->lastline;    print Dump $ver;
     #my @lines = $self->getlines;    $l->p("Current version '" . $ver->{$fw_type . ' Version'} . "'");
     #print Dump \@lines;    exit;
       
     $l->p("Checking upload ($conf->{'file_cksum'})");    if (
     my $results = $t->tftpd;      $ver->{$fw_type . ' Version'}  eq $conf->{'ver'} &&
     # check the 'File Length' against ???      $ver->{$fw_type . ' Checksum'} eq $conf->{'cksum'}
     if ( $results->{'File Checksum'} ne $conf->{'file_cksum'}) {    ) {
       $l->sp(      $l->sp("Already updated!");
         "File checksum '" . $results->{'File Checksum'} .      return 0;
         "does not match config file '" . $conf->{'file_cksum'} . "'!"    }
       );  
       next;    my $try = 0;
     }    while (1) {
     $l->p("File checksum matches . . . ");      if ($try >= $max_tries) {
         $l->sp("Couldn't update in $max_tries tries!");
     if ($results->{'File Length'}   !~ /^$conf->{'file_size'} bytes/) {        return undef;
       $l->sp(      }
         "File length '" . $results->{'File Length'} .      $try++;
         "does not match config file '" . $conf->{'file_size'} . " bytes'!"  
       );      #sysinfo($self->{'_host'});
       next;  
     }      $l->p("Enabling TFTPd");
     $l->p("File length matches . . . ");      unless ($t->enable_tftpd) {
         $l->sp("Couldn't enable tftpd");
     if ( uc($results->{'File Name'}) ne uc($conf->{'file_name'}) ) {        next;
       $l->sp(      }
         "File name '" . $results->{'File Name'} .  
         "' does not match config file '" . $conf->{'file_name'} . "'!"      $l->p("Uploading file ($file)");
       );      # use tftp to push the file up
       next;      my $tftp = Net::TFTP->new($t->Host, Mode => 'octet');
     }  
     $l->p("File name  matches . . . ");      unless ($tftp->put($file, $file)) {
         $l->sp("Error uploading: " . $tftp->error);
     $l->p("Updating flash (new checksum '$conf->{'cksum'}')");        next;
     unless ($results = $t->updateflash(      }
       $ver->{'Firmware Checksum'}, $conf->{'cksum'}  
     ) ) {      $l->p("Checking upload ($conf->{'file_cksum'})");
       $l->sp("Couldn't update flash: $!");      my $results = $t->tftpd;
       next;      # check the 'File Length' against ???
     }      if ( $results->{'File Checksum'} ne $conf->{'file_cksum'}) {
         $l->sp(
     unless (          "File checksum '" . $results->{'File Checksum'} .
       defined $results->{'Checksum'} &&          " does not match config file '" . $conf->{'file_cksum'} . "'!"
       $results->{'Checksum'} eq $conf->{'cksum'}        );
     ) {        next;
       $l->sp("Saved checksum does not match config file!");      }
       next;      $l->p("File checksum matches . . . ");
     }  
     $l->p("Uploaded checksum ($results->{'Checksum'}) " .      if ($results->{'File Length'}   !~ /^$conf->{'file_size'} bytes/) {
           "matches ($conf->{'cksum'})");        $l->sp(
               "File length '" . $results->{'File Length'} .
     $l->sp("Successfully updated!");          "does not match config file '" . $conf->{'file_size'} . " bytes'!"
     return 1;        );
   }        next;
 }      }
       $l->p("File length matches . . . ");
 sub read_conf  
 {      if ( uc($results->{'File Name'}) ne uc($conf->{'file_name'}) ) {
   my $file = shift;        $l->sp(
   my %conf;          "File name '" . $results->{'File Name'} .
   my $in_ip_list = 0;          "' does not match config file '" . $conf->{'file_name'} . "'!"
   open my $fh, $file or die "Couldn't open file $file: $!";        );
   while (<$fh>) {        next;
     chomp;      }
     next if /^#/;      $l->p("File name  matches . . . ");
     next if /^$/;  
     if ($in_ip_list) {      my $image_type = 'mainimage';
       s/\s+//g; # Whitespace is a no no      if ($fw_type eq 'FPGA') {
         $image_type = 'fpgaimage';
       if (/^(\d{1,3}\.\d{1,3}\.\d{1,3}\.)(\d{1,3})-(\d{1,3})/) {      }
         push @{ $conf{'ips'} }, $1 . $_ for ($2..$3);      $l->p("Updating $image_type (new checksum '$conf->{'cksum'}')");
       } else {      unless ($results = $t->updateflash(
         push @{ $conf{'ips'} }, $_;        args => $image_type . ' ' . $ver->{$fw_type . ' Checksum'} .
       }                ' '          . $conf->{'cksum'},
     } else {        Timeout => 90,
       my ($key, $val) = split /\s+/, $_, 2;      ) ) {
         $l->sp("Couldn't update flash: $!");
       if (lc($key) eq 'ips') {        next;
         $in_ip_list = 1;      }
         next;  
       }      unless (
         defined $results->{'Checksum'} &&
       $key =~ s/^\s+//;        $results->{'Checksum'} eq $conf->{'cksum'}
       $key =~ s/\s+$//;      ) {
       $val =~ s/^\s+//;        $l->sp("Saved checksum " . $results->{'Checksum'} . " does not match config file " .  $conf->{'cksum'} . "!");
       $val =~ s/\s+$//;        next;
       }
       $conf{ lc($key) } = $val;      $l->p("Uploaded checksum ($results->{'Checksum'}) " .
     }            "matches ($conf->{'cksum'})");
   }  
   close $fh;      $l->sp("Successfully updated!");
       return 1;
   #print Dump \%conf;    }
   foreach (  }
     'password',  
     'file_name', 'file_size', 'file_cksum',  package Mylogger;
     'ver', 'cksum', 'ips',  
   ) {  use Fcntl ':flock'; # import LOCK_* constants
     die "No $_ specified in config file!"  #use YAML;
       if (not exists $conf{$_});  use constant LOG_PRINT => 128;
   }  use constant LOG_SAVE  =>  64;
   
   #print Dump \%conf;  DESTROY {
   #exit;    my $self = shift;
   return \%conf;    if ($self->{'MYLOG'}) {
 }      $self->p("Closing log ($self->{'log_path'}/$self->{'log_file'})");
       close $self->{'MYLOG'};
 package Trango::Telnet;    }
 use base 'Net::Telnet';  }
   
 my %PRIVATE = (  sub new {
   connected => 0,    my $package = shift;
   logged_in => 0,    my $self = shift || {};
 );  
     $self->{'base_path'}  ||= '.';
 sub new {    $self->{'log_path'}   ||= $self->{'base_path'};
   my $class = shift;    $self->{'log_prefix'} ||= 'LOG';
   my $args = shift || {};    $self->{'log_file'}   ||= GetLogName(
       $self->{'log_prefix'},
   $args->{'Timeout'} ||= 5;      $self->{'log_path'}
   $args->{'Prompt'}  ||= '/#> *$/';    );
     bless $self, $package;
   foreach my $key (keys %{ $args }) {  }
     $PRIVATE{$key} = $args->{$key};  
   }  sub s
   {
   my $self = $class->SUPER::new(%{ $args });    my $self = shift;
   bless $self;    my $m = shift;
     return $self->mylog($m, LOG_SAVE);
   #bless $self, $package;  }
   return $self;  
 }  sub p
   {
 sub connect    my $self = shift;
 {    my $m = shift;
   my $self = shift;    return $self->mylog($m, LOG_PRINT);
   }
   unless ( $self->open(  
       Host => $PRIVATE{'Host'},  sub sp
       Errmode => 'return',  {
   ) ) {    my $self = shift;
     $! = "Couldn't connect to $self->{'Host'}.  Connection timed out.";    my $m = shift;
     return undef, undef;    return $self->mylog($m, LOG_SAVE | LOG_PRINT);
   }  }
   #$self->dump_log('dump.log');  
   sub mylog
   ## Login to remote host.  {
   unless ($self->waitfor(    my $self = shift;
     -match => '/password: ?$/i',  
     -errmode => "return",    my $thing = shift;
   ) ) {    chomp $thing;
     $! = "problem connecting to host ($self->{'Host'}): " . $self->lastline;  
     return undef;    my $which = shift;
   }  
     my $MYLOG;
   $self->login_banner($self->lastline);    if ($which & LOG_PRINT) {
       print $thing, "\n";
   $PRIVATE{'connected'} = 1;    }
   
   return ($self->host_type, $self->firmware_version);    if ($which & LOG_SAVE) {
 }      if ($self->{'MYLOG'}) {
         $MYLOG = $self->{'MYLOG'};
 sub login      } else {
 {        unless ($MYLOG) {
   my $self = shift;                  open ($MYLOG, '>>', $self->{'log_path'} . '/' . $self->{'log_file'})
             or die "Couldn't open logfile!\n";
   my $password = shift;          my $ofh = select $MYLOG;
           $|=1;
   $self->print($password);          select $ofh;
   unless ($self->waitfor(          $self->{'MYLOG'} = $MYLOG;
     -match => $self->prompt,  
     -errmode => "return",          $self->p("Opened log ($self->{'log_path'}/$self->{'log_file'})");
   ) ) {        }
     $! = "login ($self->{'Host'}) failed: " . $self->lastline;      }
     return undef;      flock($MYLOG, LOCK_EX);
   }      print $MYLOG (scalar gmtime), "\t", $thing, "\n"
         or die "Couldn't print to MYLOG: $!";
   $PRIVATE{'logged_in'} = 1;      flock($MYLOG, LOCK_UN);
     }
   return 1;  }
 }  
   sub GetLogName
 sub login_banner  {
 {    my $prefix  = shift || die "Invalid prefix passed for log";
   my $self = shift;  
     my $logdate = GetLogDate();
   my $banner = shift || $PRIVATE{'login_banner'};    my $logver  = 0;
     my $logname;
   my ($type, $ver) = $banner =~  
     /Welcome to Trango Broadband Wireless (\S+)[\s-]+(.+)$/i;    do {
       $logname = $prefix . $logdate . sprintf("%02d", $logver) . '.log';
   $self->host_type($type);      $logver++;
   $self->firmware_version($ver);    } until (not -e $logname);
   
   return $banner;    return $logname;
 }  }
   
 sub host_type  sub GetLogDate
 {  {
   my $self = shift;    my ($sec,$min,$hour,$mday,$mon,$year,,,) = localtime();
   
   my $type = shift || $PRIVATE{'host_type'};    $mon++;
   $PRIVATE{'host_type'} = $type;    $year += 1900;
   
   return $type;    if ($min  < 10) { $min  = "0$min"  }
 }    if ($sec  < 10) { $sec  = "0$sec"  }
     if ($hour < 10) { $hour = "0$hour" }
 sub firmware_version    if ($mday < 10) { $mday = "0$mday" }
 {    if ($mon  < 10) { $mon  = "0$mon"  }
   my $self = shift;  
     my $time = $year . $mon . $mday;
   my $ver = shift || $PRIVATE{'firmware_version'};  
   $PRIVATE{'firmware_version'} = $ver;    return $time;
     }
   return $ver  
 }  
   
 sub Host  
 {  
   my $self = shift;  
     
   my $host = shift || $PRIVATE{'Host'};  
   $PRIVATE{'HOST'} = $host;  
   
   return $host;  
 }  
   
   
 sub reboot  
 {  
   my $self = shift;  
   
   $self->print("reboot\n");  
   $self->getline;  
   
   return 1;  
 }  
   
 sub exit  
 {  
   my $self = shift;  
   
   $self->print("exit\n");  
   $self->getline;  
   
   return 1;  
 }  
   
 sub ver  
 {  
   my $self = shift;  
   
   return $self->cmd('ver');  
 }  
   
 sub tftpd  
 {  
   my $self = shift;  
   
   return $self->cmd('tftpd', 'Success.');  
 }  
   
 sub sysinfo  
 {  
   my $self = shift;  
   
   return $self->cmd('sysinfo', 'Success.');  
 }  
   
 sub enable_tftpd  
 {  
   my $self = shift;  
   
   my $vals = $self->cmd('tftpd on', 'Success.');  
   
   if ($vals->{'Tftpd'} eq 'listen') {  
     return $vals;  
   } else {  
     return undef;  
   }  
 }  
   
 sub updateflash  
 {  
   my $self = shift;  
   
   my $old = shift;  
   my $new = shift;  
   
   return undef unless $new;  
   
   return $self->cmd("updateflash mainimage $old $new", 'Success.', 90);  
 }  
   
 sub cmd  
 {  
   my $self = shift;  
   
   my $string = shift;  
   my $expect_last = shift;  
   my $timeout = shift || $PRIVATE{'Timeout'};  
   
   unless (defined $string) {  
     $! = "No command passed";  
     return undef;  
   }  
   
   unless ($PRIVATE{'connected'}) {  
     $! = "Not connected";  
     return undef;  
   }  
   
   unless ($PRIVATE{'logged_in'}) {  
     $! = "Not logged in";  
     return undef;  
   }  
   
   my @lines = $self->SUPER::cmd(String => $string, Timeout => $timeout);  
   
   my $vals = _decode_lines(@lines);  
   
   unless ($expect_last) {  
     return $vals;  
   }  
   
   my $last = $self->lastline;  
   
   if ($last =~ /$expect_last$/) {  
     return $vals;  
   } else {  
     warn "Error with command ($string): $last";  
     return undef;  
   }  
 }  
   
 sub _decode_lines  
 {  
   my @lines = @_;  
   
   my %conf;  
   
   my $key = '';  
   my $val = '';  
   my $in_key = 0;  
   my $in_val = 0;  
   
   foreach my $line (@lines) {  
     my @chars = split //, $line;  
   
     my $last_key = '';  
     foreach my $c (@chars) {  
   
       if ($c eq '[' || $c eq "\r" || $c eq "\n") {  
         if ($c eq '[') {  
           $in_key = 1;  
           $in_val = 0;  
         } else {  
           $in_key = 0;  
           $in_val = 0;  
         }  
   
         if ($key) {  
           $key =~ s/^\s+//;  
           $key =~ s/\s+$//;  
   
           $val =~ s/^\s+//;  
           $val =~ s/\s+$//;  
   
           if ($key eq 'Checksum' && $last_key) {  
             # Special case for these bastids.  
             my $new = $last_key;  
             $new =~ s/\s+\S+$//;  
             $key = $new . " " . $key;  
           }  
   
           $last_key = $key;  
           $conf{$key} = $val;  
           $key = '';  
           $val = '';  
         }  
   
       } elsif ($c eq ']') {  
         $in_val = 1;  
         $in_key = 0;  
         $c = shift @chars;  
   
       } elsif ($in_key) {  
         $key .= $c;  
   
       } elsif ($in_val) {  
         $val .= $c;  
       }  
     }  
   }  
   #print Dump \%conf;  
   
   if (%conf) {  
     return \%conf;  
   } else {  
     return \@lines;  
   }  
 }  
   
   
   
 package Mylogger;  
   
 use Fcntl ':flock'; # import LOCK_* constants  
 #use YAML;  
 use constant LOG_PRINT => 128;  
 use constant LOG_SAVE  =>  64;  
   
 DESTROY {  
   my $self = shift;  
   if ($self->{'MYLOG'}) {  
     $self->p("Closing log ($self->{'log_path'}/$self->{'log_file'})");  
     close $self->{'MYLOG'};  
   }  
 }  
   
 sub new {  
   my $package = shift;  
   my $self = shift || {};  
   
   $self->{'base_path'}  ||= '.';  
   $self->{'log_path'}   ||= $self->{'base_path'};  
   $self->{'log_prefix'} ||= 'LOG';  
   $self->{'log_file'}   ||= GetLogName(  
     $self->{'log_prefix'},  
     $self->{'log_path'}  
   );  
   bless $self, $package;  
 }  
   
 sub s  
 {  
   my $self = shift;  
   my $m = shift;  
   return $self->mylog($m, LOG_SAVE);  
 }  
   
 sub p  
 {  
   my $self = shift;  
   my $m = shift;  
   return $self->mylog($m, LOG_PRINT);  
 }  
   
 sub sp  
 {  
   my $self = shift;  
   my $m = shift;  
   return $self->mylog($m, LOG_SAVE | LOG_PRINT);  
 }  
   
 sub mylog  
 {  
   my $self = shift;  
   
   my $thing = shift;  
   chomp $thing;  
   
   my $which = shift;  
   
   my $MYLOG;  
   if ($which & LOG_PRINT) {  
     print $thing, "\n";  
   }  
   
   if ($which & LOG_SAVE) {  
     if ($self->{'MYLOG'}) {  
       $MYLOG = $self->{'MYLOG'};  
     } else {  
       unless ($MYLOG) {  
                 open ($MYLOG, '>>', $self->{'log_path'} . '/' . $self->{'log_file'})  
           or die "Couldn't open logfile!\n";  
         my $ofh = select $MYLOG;  
         $|=1;  
         select $ofh;  
         $self->{'MYLOG'} = $MYLOG;  
   
         $self->p("Opened log ($self->{'log_path'}/$self->{'log_file'})");  
       }  
     }  
     flock($MYLOG, LOCK_EX);  
     print $MYLOG (scalar gmtime), "\t", $thing, "\n"  
       or die "Couldn't print to MYLOG: $!";  
     flock($MYLOG, LOCK_UN);  
   }  
 }  
   
 sub GetLogName  
 {  
   my $prefix  = shift || die "Invalid prefix passed for log";  
   
   my $logdate = GetLogDate();  
   my $logver  = 0;  
   my $logname;  
   
   do {  
     $logname = $prefix . $logdate . sprintf("%02d", $logver) . '.log';  
     $logver++;  
   } until (not -e $logname);  
   
   return $logname;  
 }  
   
 sub GetLogDate  
 {  
   my ($sec,$min,$hour,$mday,$mon,$year,,,) = localtime();  
   
   $mon++;  
   $year += 1900;  
   
   if ($min  < 10) { $min  = "0$min"  }  
   if ($sec  < 10) { $sec  = "0$sec"  }  
   if ($hour < 10) { $hour = "0$hour" }  
   if ($mday < 10) { $mday = "0$mday" }  
   if ($mon  < 10) { $mon  = "0$mon"  }  
   
   my $time = $year . $mon . $mday;  
   
   return $time;  
 }  

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.22

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