I received the following message via private mail.  It includes
a wrapper program to MHonArc to manage monthly-based archives
in manner similar to the various Procmail recipies posted to
the list.  Since the author states it is okay to pass along, I
I shall in-case anyone may have interest in it.




Hi Earl,

Thanks for MHonArc!  I have used it in the past and am just now setting it
up again.  The first time I learned my lesson about high volume mail
archives getting out of hand.  This time I looked around to see if there
were any tools for automatically splitting the archives by month to keep
the size of the archives managable.  Not finding anything I added a
bit to your example from the FAQ and came up with this little perl wrapper
for MHonArc.   I am sure it could be improved greatly, but the code works
for me and is basically self documented.  Feel free to spread it around if
you think others might use it.

Thanks again,

Tom
 
======================================================================
   "Z-80 system stack overflow.  Shut 'er down Scotty, the system's
         sucking mud" - Error message on TRS 80 Model-16B

Thomas D. Simes                                   [EMAIL PROTECTED] 
======================================================================
#!/usr/local/bin/perl
# Edit above path to point to where perl is on your system.
#
# Wrapper for MHonArc to split mail archives into Year-Month directories

## Specify a package to protect variable names from MHonArc.
package Run_MHonArc;

## Get name of list and path to mail file being processed from command line
$list_name=$ARGV[0];
$mail_file=$ARGV[1];
if (!$list_name || !$mail_file)
        {
        print "usage: run_mhonarc.pl list_name full_mailfile_path\n";
        }
else

{

##       Edit to point at path to mhonarc
$MHonArc = "/usr/local/bin/mhonarc"; 

##       Edit to point at archive directory on your webserver
$archive_root = "/usr/local/www/data/mail";

##      Date stuff for directory name may need to be adjusted for your
##      local flavor of localtime

$month = ("January", "February", "March", "April", "May", "June", "July", "August", 
"September", "October", "November", "December")[(localtime)[4]];
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
$year += 1900; # Y2K proof - localtime returns 101 for the year 2001

##      Figure out output directory and create if it doesn't exist

$out_dir = "$archive_root/$list_name/$year-$month";
if ( ! -e $out_dir )
        {
        mkdir $out_dir, 0755 or die "Couldn't create $out_dir: $!\n";
        }

##      Define ARGV (ARGV is same across all packages).
##      Edit options as required/desired.

@args = ("-add",
         "-quiet",
         "-sort",
         "-reverse",
         "-outdir", "$out_dir",
         "$mail_file");

##      I use system() to fork MHonArc so I can return and unlink $mail_file

$result = system($MHonArc, @args);

##      Check to see if all went well before unlinking $mail_file

if ($result == 0) {
        unlink $mail_file;      
        }
}


Reply via email to