[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mhonarc
Subject:    RE: Processing months of archives
From:       Loong Jackson-ljl004 <ljl004 () email ! mot ! com>
Date:       2000-07-24 19:56:17
[Download RAW message or body]

I used a similar approach but take one step further which also update the
top level index.html file to insert 2 URL for the respective index files.

if ( ! -d $outdir ) {
    # oops! it's missing, let's create it
    mkdir $outdir, 0755;
    # we need to update the master index file
    $index = $basedir . "index.html";
    
    if ( -e $index ) {
        $saved = $index . "~";
        if ( rename $index, $saved ) {
           open(OUT,">$index") || die "cannot open target index file: $index
$!\n";
           open(REF,"$saved" ) || die "cannot open reference index: $saved
$!\n";
           while(<REF>){
           # copy line by line
               print OUT $_;
               if ( $_ =~ /index starts here/ ) {
                   # add in new index for this month
                   print OUT "<tr>";
                   print OUT "<td>$month</td>";
                   print OUT "<td>[<A
HREF=\"$month/index.html\">date</A>]</td>";
                   print OUT "<td>[<A
HREF=\"$month/threads.html\">thread</A>]</td>";
                   print OUT "</tr>\n";
               }
           }
           close(OUT);
           close(REF);
           # change file protection for index
           chmod 0666, $index;
        }
    }
}

However, I'm struggling in file protection rights.  Since my pipe is done
within the mail aliases file, the script inherited ownership of
"daemon:other".  The default umask of "daemon:other" is rw-r-----.  This
means the web server cannot read the output files.  Is there an easy way to
change this?

Regards,
Jackson


-----Original Message-----
From: Andrew McGregor [mailto:andrew@niss.ac.uk]
Sent: Tuesday, February 08, 2000 5:18 AM
To: Email Archive
Cc: mhonarc@ncsa.uiuc.edu
Subject: Re: Processing months of archives


to archive on a monthly basis i filter my mails in a .forward
file and then call a pl script.  pls note our email is not 
sendmail but exim (www.exim.org) so i dont know if sendmail 
supports the same commands.


# .forward
#Exim filter
if error_message then finish endif

# Get todays month and year and pipe content off
if $tod_log matches "^(....-..)"
then
	pipe "/path-to-scripts/Add2Exploder.pl ${local_part} ${1}"
endif






# Add2Archive.pl
#!/usr/local/bin/perl
# Script to create dated mhonarc forums for Eduserv Exploder
# Usage "cat message | AddArchive.pl <rcfile-prefix> <date>"
# e.g.	"Add2Archive.pl niss 1999-12"

# Designed for use with exim and specifically to allow the creation
# of directories on the fly.


# Static Vars
my $docdir = '/path-to-htdocs/exploder';
my $confdir = '/path-to-config/exploder';

# Get Runtime Args
my $local_part = shift;
my $month = shift;

# Set output directory and the config file accordingly
my $outdir = "$docdir/$local_part/$month";
my $config = "$confdir/$local_part" . "-exploder.rc";

# Include MhOnarc code
require 'mhamain.pl';

# Create Date directory if it doesn't exist
unless ( -d "$outdir" )

  mkdir "$outdir",0755 or die "$0: failed to create dir: $outdir: $!\n";


# Initialise Mhonarc

mhonarc::initialize();

# Process Message
mhonarc::process_input(
		'-add',
		'-quiet',
		'-nodoc',
		'-rcfile', "$config",
		'-outdir', "$outdir",
		);



Email Archive wrote:
> 
> Hiya all,
> 
> I am working on getting mhonarc setup. Anyone have any pretty
> rc files that i can use as examples? I also have the problem
> that I have been archiving email for months and months
> in one large file per email list. Does anyone know of a way
> to split up this file so mhonarc can process it on a month
> by month basis? How can I automate this month by month processing
> for the future? I would like to archive it as email comes in
> but once a month.. generate new web pages and link them to
> a main index page so users can just view a specific month
> of a mailing list.
> 
> Thanks.. Mike

-- 
Andrew McGregor, EduServ (NISS), PO BOX 2674, BATH, BA2 7XY.
T: 01225 826 826 ext. 3419; F: 01225 826 177; E: am@niss.ac.uk
e-mail to mobile < 140 chars: andrew.mcgregor@sms.genie.co.uk

[Attachment #3 (text/html)]

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2650.12">
<TITLE>RE: Processing months of archives</TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=2>I used a similar approach but take one step further which also update \
the top level index.html file to insert 2 URL for the respective index \
files.</FONT></P>

<P><FONT SIZE=2>if ( ! -d $outdir ) {</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; # oops! it's missing, let's create it</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; mkdir $outdir, 0755;</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; # we need to update the master index file</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; $index = $basedir . \
&quot;index.html&quot;;</FONT> <BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; </FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; if ( -e $index ) {</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $saved = $index . \
&quot;~&quot;;</FONT> <BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if \
( rename $index, $saved ) {</FONT> <BR><FONT \
SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
open(OUT,&quot;&gt;$index&quot;) || die &quot;cannot open target index file: $index \
$!\n&quot;;</FONT> <BR><FONT \
SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
open(REF,&quot;$saved&quot; ) || die &quot;cannot open reference index: $saved \
$!\n&quot;;</FONT> <BR><FONT \
SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
while(&lt;REF&gt;){</FONT> <BR><FONT \
SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # copy line by \
line</FONT> <BR><FONT \
SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
print OUT $_;</FONT> <BR><FONT \
SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
if ( $_ =~ /index starts here/ ) {</FONT> <BR><FONT \
SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
# add in new index for this month</FONT> <BR><FONT \
SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
print OUT &quot;&lt;tr&gt;&quot;;</FONT> <BR><FONT \
SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
print OUT &quot;&lt;td&gt;$month&lt;/td&gt;&quot;;</FONT> <BR><FONT \
SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
print OUT &quot;&lt;td&gt;[&lt;A \
HREF=\&quot;$month/index.html\&quot;&gt;date&lt;/A&gt;]&lt;/td&gt;&quot;;</FONT> \
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
print OUT &quot;&lt;td&gt;[&lt;A \
HREF=\&quot;$month/threads.html\&quot;&gt;thread&lt;/A&gt;]&lt;/td&gt;&quot;;</FONT> \
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
print OUT &quot;&lt;/tr&gt;\n&quot;;</FONT> <BR><FONT \
SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
}</FONT> <BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
}</FONT> <BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
close(OUT);</FONT> <BR><FONT \
SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
close(REF);</FONT> <BR><FONT \
SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # change file \
protection for index</FONT> <BR><FONT \
SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; chmod 0666, \
$index;</FONT> <BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp; }</FONT>
<BR><FONT SIZE=2>}</FONT>
</P>

<P><FONT SIZE=2>However, I'm struggling in file protection rights.&nbsp; Since my \
pipe is done within the mail aliases file, the script inherited ownership of \
&quot;daemon:other&quot;.&nbsp; The default umask of &quot;daemon:other&quot; is \
rw-r-----.&nbsp; This means the web server cannot read the output files.&nbsp; Is \
there an easy way to change this?</FONT></P>

<P><FONT SIZE=2>Regards,</FONT>
<BR><FONT SIZE=2>Jackson</FONT>
</P>
<BR>

<P><FONT SIZE=2>-----Original Message-----</FONT>
<BR><FONT SIZE=2>From: Andrew McGregor [<A \
HREF="mailto:andrew@niss.ac.uk">mailto:andrew@niss.ac.uk</A>]</FONT> <BR><FONT \
SIZE=2>Sent: Tuesday, February 08, 2000 5:18 AM</FONT> <BR><FONT SIZE=2>To: Email \
Archive</FONT> <BR><FONT SIZE=2>Cc: mhonarc@ncsa.uiuc.edu</FONT>
<BR><FONT SIZE=2>Subject: Re: Processing months of archives</FONT>
</P>
<BR>

<P><FONT SIZE=2>to archive on a monthly basis i filter my mails in a .forward</FONT>
<BR><FONT SIZE=2>file and then call a pl script.&nbsp; pls note our email is not \
</FONT> <BR><FONT SIZE=2>sendmail but exim (www.exim.org) so i dont know if sendmail \
</FONT> <BR><FONT SIZE=2>supports the same commands.</FONT>
</P>
<BR>

<P><FONT SIZE=2># .forward</FONT>
<BR><FONT SIZE=2>#Exim filter</FONT>
<BR><FONT SIZE=2>if error_message then finish endif</FONT>
</P>

<P><FONT SIZE=2># Get todays month and year and pipe content off</FONT>
<BR><FONT SIZE=2>if $tod_log matches &quot;^(....-..)&quot;</FONT>
<BR><FONT SIZE=2>then</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>pipe \
&quot;/path-to-scripts/Add2Exploder.pl ${local_part} ${1}&quot;</FONT> <BR><FONT \
SIZE=2>endif</FONT> </P>
<BR>
<BR>
<BR>
<BR>
<BR>

<P><FONT SIZE=2># Add2Archive.pl</FONT>
<BR><FONT SIZE=2>#!/usr/local/bin/perl</FONT>
<BR><FONT SIZE=2># Script to create dated mhonarc forums for Eduserv Exploder</FONT>
<BR><FONT SIZE=2># Usage &quot;cat message | AddArchive.pl &lt;rcfile-prefix&gt; \
&lt;date&gt;&quot;</FONT> <BR><FONT SIZE=2># e.g.&nbsp; &quot;Add2Archive.pl niss \
1999-12&quot;</FONT> </P>

<P><FONT SIZE=2># Designed for use with exim and specifically to allow the \
creation</FONT> <BR><FONT SIZE=2># of directories on the fly.</FONT>
</P>
<BR>

<P><FONT SIZE=2># Static Vars</FONT>
<BR><FONT SIZE=2>my $docdir = '/path-to-htdocs/exploder';</FONT>
<BR><FONT SIZE=2>my $confdir = '/path-to-config/exploder';</FONT>
</P>

<P><FONT SIZE=2># Get Runtime Args</FONT>
<BR><FONT SIZE=2>my $local_part = shift;</FONT>
<BR><FONT SIZE=2>my $month = shift;</FONT>
</P>

<P><FONT SIZE=2># Set output directory and the config file accordingly</FONT>
<BR><FONT SIZE=2>my $outdir = &quot;$docdir/$local_part/$month&quot;;</FONT>
<BR><FONT SIZE=2>my $config = &quot;$confdir/$local_part&quot; . \
&quot;-exploder.rc&quot;;</FONT> </P>

<P><FONT SIZE=2># Include MhOnarc code</FONT>
<BR><FONT SIZE=2>require 'mhamain.pl';</FONT>
</P>

<P><FONT SIZE=2># Create Date directory if it doesn't exist</FONT>
<BR><FONT SIZE=2>unless ( -d &quot;$outdir&quot; )</FONT>
</P>

<P><FONT SIZE=2>&nbsp; mkdir &quot;$outdir&quot;,0755 or die &quot;$0: failed to \
create dir: $outdir: $!\n&quot;;</FONT> </P>
<BR>

<P><FONT SIZE=2># Initialise Mhonarc</FONT>
</P>

<P><FONT SIZE=2>mhonarc::initialize();</FONT>
</P>

<P><FONT SIZE=2># Process Message</FONT>
<BR><FONT SIZE=2>mhonarc::process_input(</FONT>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>'-add',</FONT> \
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>'-quiet',</FONT> \
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>'-nodoc',</FONT> \
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>'-rcfile', \
&quot;$config&quot;,</FONT> <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>'-outdir', \
&quot;$outdir&quot;,</FONT> <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2>);</FONT> </P>
<BR>
<BR>

<P><FONT SIZE=2>Email Archive wrote:</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; Hiya all,</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; I am working on getting mhonarc setup. Anyone have any \
pretty</FONT> <BR><FONT SIZE=2>&gt; rc files that i can use as examples? I also have \
the problem</FONT> <BR><FONT SIZE=2>&gt; that I have been archiving email for months \
and months</FONT> <BR><FONT SIZE=2>&gt; in one large file per email list. Does anyone \
know of a way</FONT> <BR><FONT SIZE=2>&gt; to split up this file so mhonarc can \
process it on a month</FONT> <BR><FONT SIZE=2>&gt; by month basis? How can I automate \
this month by month processing</FONT> <BR><FONT SIZE=2>&gt; for the future? I would \
like to archive it as email comes in</FONT> <BR><FONT SIZE=2>&gt; but once a month.. \
generate new web pages and link them to</FONT> <BR><FONT SIZE=2>&gt; a main index \
page so users can just view a specific month</FONT> <BR><FONT SIZE=2>&gt; of a \
mailing list.</FONT> <BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; Thanks.. Mike</FONT>
</P>

<P><FONT SIZE=2>-- </FONT>
<BR><FONT SIZE=2>Andrew McGregor, EduServ (NISS), PO BOX 2674, BATH, BA2 7XY.</FONT>
<BR><FONT SIZE=2>T: 01225 826 826 ext. 3419; F: 01225 826 177; E: \
am@niss.ac.uk</FONT> <BR><FONT SIZE=2>e-mail to mobile &lt; 140 chars: \
andrew.mcgregor@sms.genie.co.uk</FONT> </P>

</BODY>
</HTML>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic