mhonarc-users

Re: ezmlm-mhonarc script does not work !!!

1999-04-22 04:45:31
At 02:36 25/04/99 +1000, Yin Tan Cui <paul(_at_)sydney(_dot_)net> wrote:
Hi,

I found the script posted by Earl Hood for automatically creating
a directory year-month in the archive.

I make a modification to the script.

[snip]

I'm not quite sure if the syntax is right. All I know is that
script does not work. I'm not a perl programmer. so I'm not sure
where the mistake is... 

Hi,  

I'm a terrible perl hacker as well, and also borrowed Earl's (untested)
template for my own, similar, use. My script is attached below, sorry it's
so long, but it also puts the month and year into the title of the archive,
and I hope it helps.

Cheers,
Phil Watkinson,
Boston, UK.

#!/usr/bin/perl
#
# mhonarc-update.perl
# PK Watkinson 22-Mar-99
#
# Custom version of MHonArc to create monthly-based archives.
# This program will be called from an MTA as the messages arrive.

## Location of MHonArc libraries on this system
use lib qw( /usr/lib/perl5/site_perl );

MAIN: {
    use strict;

    ## Base location of monthly directories
    my( $archivedir ) = '/var/www/archives/html/';

    ## Set umask here since we will be doing some of our own stuff.
    umask 022;

    ## Load main MHonArc library
    require 'mhamain.pl' || die qq/ERROR: Unable to require mhamain.pl"\n/;
    mhonarc::initialize();

    ## Find current month and year
    my($thismonth) = `/bin/date '+%Y-%m'`;
    my($month) = substr( $thismonth, 5, 2 );
    my($year)  = substr( $thismonth, 0, 4 );

    $archivedir = $archivedir . $year . "-" . $month;

    ## Find name of month
    my($monthname) = "Unknown";
    if ($month eq "01") { $monthname = "January " . $year }
       elsif ($month eq "02") { $monthname = "February " . $year }
       elsif ($month eq "03") { $monthname = "March " . $year }
       elsif ($month eq "04") { $monthname = "April " . $year }
       elsif ($month eq "05") { $monthname = "May " . $year }
       elsif ($month eq "06") { $monthname = "June " . $year }
       elsif ($month eq "07") { $monthname = "July " . $year }
       elsif ($month eq "08") { $monthname = "August " . $year }
       elsif ($month eq "09") { $monthname = "September " . $year }
       elsif ($month eq "10") { $monthname = "October " . $year }
       elsif ($month eq "11") { $monthname = "November " . $year }
       elsif ($month eq "12") { $monthname = "December " . $year }

    ## variables are not evaluated inside single quotes, so
    ## can only pass strings this way:
    my($datestr)   = "Date Index for " . $monthname;
    my($threadstr) = "Thread Index for " . $monthname;

    ## Call MHonArc functions to add message.
    mhonarc::process_input(
    '-add',
    '-rcfile', '/var/www/archives/mhonarc.rc',
    '-quiet',
    '-outdir', $archivedir,
    '-title',  $datestr,
    '-ttitle', $threadstr
     ) ? exit(0) : exit($mhonarc::CODE);
}

  

<Prev in Thread] Current Thread [Next in Thread>