#!/usr/bin/perl
  @MoY=('Jan','Feb','Mar','Apr','May','Jun',
           'Jul','Aug','Sep','Oct','Nov','Dec');
require '/usr/local/bin/jpltime.pl';

print "Do not run this script. it's not tested. --Robert\n";
exit(1);

opendir(DIR,"/home/ftp/pub/station/finallog/");
@logs=grep !/^\./,readdir(DIR);
closedir DIR;
#opendir(DIR,"fixedoldlogs/");
#@logs=grep !/^\./,readdir(DIR);
#closedir DIR;
#$igldir="/home/ftp/pub/station/iglos_log_submissions/";
closedir DIR;

foreach $log (@logs) {
  if ($log =~ /^(....)(\d\d)(\d\d)\.log/) {
    $site4=$1;
    $mm=$3;
    $yyyy=$2;  $yyyy += ($yy>80)? 1900 : 2000;
    open(GREP,"grep -s \'Date Prepared\' fixedoldlogs/$log|");
    while (<GREP>) {
      $prepline=$_;
    }
    close GREP;
    chop $prepline;
    ($label,$date)=split(': ',$prepline);
    ($dd,$mmm,$prepyyyy)=split('-',$date);
    for ($i=0; $i <= $#MoY; $i++) {
        if ($mmm =~ /$MoY[$i]/i) { $mon = $i+1;}
    }
    $newlogname=$site4.'_'.$yyyy.$mm.$dd.'.log';
    `/home/igscb/ctl/cron/nu_writesnx/writesnx -n -h </home/ftp/pub/station/finallog/$log>/home/ftp/pub/station/finallog/conversions/$newlogname 2>/home/ftp/pub/station/finallog/conversions/$site4.newcode`;
#    `writesnx.anew -h -n <4kurt/$log>/dev/null 2>kurtfixes/$site4.newcode`;
#    `/home/igscb/ctl/cron/nu_writesnx/writesnx.anew -s /dev/null <$igldir/$log 2>igloslogfixes/$site4`;
    if (-s "conversions/$site4.newcode") {
      # there were errs
      unlink <conversions/$newlogname>;
     `cp /home/ftp/pub/station/finallog/$log conversions/`; 
      `grep \'new code\' conversions/$site4.newcode >>conversions/$site4`;
    }
    else {
      # no errs
      unlink <conversions/$site4.newcode>;
    }
  }
}
