I have been using the O'Reilly book "Managing Mailing Lists" to help me set up a SmartList mailing list. Within the book, the section on archives shows a perl script to save messages in an archive organized in "/archive/YYMM/DD" format. I typed the script in and have found it to work just fine with the exception of what looks like a Y2K bug. Instead of creating a YYMM directory having a name of "0008" it creates one with the name of "10008". I think this means it calculates the year as being 100, which is one more than 99 (1999). I have included the script in this email. Any ideas in correcting this problem? Thank you (arch_trunc script replacement from O'Reilly & Associates Managing Mailing Lists) ----------------------------------------------------------------------------------------------------------------------------------------------------------------- #!/usr/bin/perl # # arch_trunc, a replacement for the distributed ./bin/arch_trunc # shell script in SmartList. To use it, put it in some list's directory. # # By Alan Schwartz # # This script is run whenever a submission is received and archived # in archive/latest. It's responsible for cleaning up that directory. # This version figures out the date of each file in archive/latest # that should be removed and appends it to the file archive/YYMM/DD # unless (chdir("archive/latest")) { print "Don't start this script directly, it is called by rc.request\n"; exit 64 } # Only do the removing now and then to keep load down #if ($ENV{'ARCHIVE'} =~ /[248]$/) { opendir(DIR,"."); @files = grep(/^\d+/,readdir(DIR)); closedir (DIR); foreach (sort bytime @files) { $recent++; if ($recent > $ENV{'archive_hist'}) { # Archive these and delete them @time = localtime((stat($_))[9]); $newdir = sprintf("%02d%02d",$time[5],$time[4]+1); $newfile = sprintf("%02d",$time[3]); unless (-d "../$newdir") { mkdir("../$newdir",2770); } open(IN,$_); open(OUT,">>../$newdir/$newfile"); print OUT <IN>; close(IN); close(OUT); unlink($_); } } unlink("_dummy_"); #} sub bytime { return -M $a <=> -M $b; } ----------------------------------------------------------------------------------------------------------------------- -- _________________________________________ Dave G. Bacon Computer Network Manager Outagamie Waupaca Library System 225 N. Oneida St., Appleton, WI 54911 920/832-6193(voice), 920/832-6422(FAX) dbacon@mail.owls.lib.wi.us _________________________________________
On Mon, Aug 07, 2000 at 02:19:52PM -0500, Dave Bacon wrote:
I typed the script in and have found it to work just fine with the exception of what looks like a Y2K bug. Instead of creating a YYMM directory having a name of "0008" it creates one with the name of "10008". I think this means it calculates the year as being 100, which is one more than 99 (1999). I have included the script in this email. Any ideas in correcting this problem? Thank you
Alas, O'Reilly, how thou art fallen!
$newdir = sprintf("%02d%02d",$time[5],$time[4]+1);
Should be $newdir = sprintf("%04d%02d",$time[5]+1900,$time[4]+1); for a YYYYMM archive directory. If you want to keep using the old style, $newdir = sprintf("%02d%02d",$time[5]%100,$time[4]+1); R -- Roger Burton West -/- roger@firedrake.org http://firedrake.org/roger/
participants (2)
-
Dave Bacon
-
Roger Burton West