Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 17 Aug 2001 22:35:22 -0500
From:      jacks@sage-american.com
To:        parv <parv_@yahoo.com>
Cc:        Duke Normandin <01031149@3web.net>, Freebsd Questions <freebsd-questions@FreeBSD.ORG>
Subject:   Re: Script to strip email headers??
Message-ID:  <3.0.5.32.20010817223522.01125e10@mail.sage-american.com>
In-Reply-To: <20010817223256.A88127@moo.holy.cow>
References:  <3.0.5.32.20010817205856.01158a10@mail.sage-american.com> <no.id> <20010817140800.A116607@mandy.rockingd.calgary.ab.ca> <3.0.5.32.20010817205856.01158a10@mail.sage-american.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Okay, here is the WHOLE script "archive.pl" by Alan Millar....

Let me know what you think... thanks!

******************************************************************************
#!/usr/bin/perl

#(Message inbox:15)
#Return-Path: Majordomo-Users-Owner@greatcircle.com
#Message-Id: <m0oXmfl-0002wDC@hock.bolis.sf-bay.org>
#From: Alan Millar <amillar@bolis.sf-bay.org>
#Subject: Perl prog to create list archives
#To: majordomo-users@greatcircle.com
#Date: Wed, 1 Sep 1993 00:32:03 -0800 (PDT)
#Cc: brent@greatcircle.com
#Reply-To: Alan Millar <AMillar@bolis.sf-bay.org>
#
#
#Hi-
#
#Here is a perl program I wrote to keep mailing list archives.  
#It is designed to produce list archive files similar to Revised
#Listserv.  Each message is separated by a line of "==="s and
#most of the header "noise" is gone.  Instead of being stored
#in one big file, they are split into one file per month with
#the name logYYMM where YY and MM are the numeric year and
#month.
#
#I call it from /usr/lib/aliases using:
#
#  listname-archive:	"|/usr/local/mail/majordomo/wrapper archive.pl \
#		/usr/local/mail/lists/listname.archive"
#
#Where the last parameter is the directory name to put the
#log files into.
#
#Give it a try and let me know what you think.
#
#- Alan
#
#----                                                            ,,,, 
#Alan Millar            amillar@bolis.SF-Bay.org              __oo  \  
#System Administrator                                           =___/
#The skill of accurate perception is called cynicism by those who don't 
#possess it.
#----


# archive.pl
# Mailing list archiver.  Specify the directory (not the file)
#  on the command line.  Messages are written to a file 
#  called 'logYYMM' in that directory, where YY is the two digit 
#  year and MM is the two-digit month.

# Written by Alan Millar August 25 1993.  

# All these should be in the standard PERL library
unshift(@INC, $homedir);
require "majordomo.pl";		# all sorts of general-purpose Majordomo subs
require "shlock.pl";		# NNTP-style file locking

# The headers we want to keep, in order:
@keepHeaders = 
  ( "To", "cc"
  , "from", "reply-to", "organization"
  , "date", "subject"
  , "summary", "keywords"
  , "Content-Type"
  );

#-----------------------------------
# Set up output file.  See if directory is specified on command line.
$outputDir = $ARGV[0];
if (! -d $outputDir) {
    $outputDir = "/tmp"; 
}
$outputDir =~ s/\/$//; # drop trailing slash

#------------------------------------
# Get date for log file name
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);

# log file name is form "logYYMM"
$logFile = sprintf("$outputDir/log%2.2d%2.2d",$year,$mon + 1);

# open output file
&lopen(OUTPUT,">>",$logFile);

# Parse the mail header of the message, so we can figure out who to reply to
&ParseMailHeader(STDIN, *hdrs);

# Print the headers we want

print OUTPUT "========================================";
print OUTPUT "======================================\n";

foreach $key (@keepHeaders) {
  $key =~ tr[A-Z][a-z];
  if (defined($hdrs{$key})) {
    $newKey = $key; substr($newKey,0,1) =~ tr/a-z/A-Z/;
    printf OUTPUT "%-15s%s\n", "$newKey: ", $hdrs{$key};
  } # if non-blank
} # foreach

print OUTPUT "\n";

# copy the rest of the message

while (<STDIN>) {
    print OUTPUT $_;
}
print OUTPUT "\n";

&lclose(OUTPUT);
******************************************************************************


At 10:32 PM 8.17.2001 -0400, parv wrote:
>this was, on the fateful occasion around Aug 17 21:58 -0400,
>sent by jacks@sage-american.com                                      
>>
>> 
>> So, there is a Perl5 script "archive.pl" in:
>> #/usr/local/majordomo/Tools
>> that should remove the "noise" of the extra headers and places a separator
>> line of "====" between each message...THAT WOULD BE PERFECT!!! However, not
>...
>> Have you looked at this one...? I've really got the same need, so if you
>> find a better solution, please let me know. If you know how to do some
>> Perl5, then the ideas in archive2.pl look good. Let me know. Thanks!
>
>could you mail me the perl program, or post it for those of us who 
>don't have majorodomo installed, to see if i could something as long
>as it's not too hairy.
>
>
>
>To Unsubscribe: send mail to majordomo@FreeBSD.org
>with "unsubscribe freebsd-questions" in the body of the message
>
>

Best regards,
Jack L. Stone,
Server Admin

Sage-American
http://www.sage-american.com
jacks@sage-american.com

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3.0.5.32.20010817223522.01125e10>