Perl script to convert a majordomo archive that is only Exchange emails.. Archive file is hard coded.. currently it overwrites the original file. All it does is follow the exchange threads and adds in the correct in-reply-to header so mhonarc will parse correctly.
#!/usr/bin/perl #convert.pl use strict; my ($messageNum,$lineNum,@messages,$line,$start,$filename,@file, $a,$i,$j,$indexA,$indexB,%hash,$messageID,$threadID,$stringMID, $stringTID,@queue,$inreply,$modifyA,$modifyB ); $filename = "/opt/majordomo-1.94.5/archives/ruby/ruby.200307"; ## Copy File to Array open(FILE, $filename) ; @file = <FILE>; close STATUS; $start = "^From owner-"; $messageID = "^Message-I[Dd]:"; $threadID = "^Thread-Index:"; $inreply = "^In-Reply-To:"; $messageNum = -1; ## Copy Array to multi array, with message per element for $line (@file) { if ( grep(/$start/,$line) ) { $messageNum++; $lineNum = 0; $messages[$messageNum][$lineNum++] = $line; } else { $messages[$messageNum][$lineNum++] = $line; } } @queue = (); ## Build hash table of Message-ID to Thread-Index ## Build Queue for root Thread-Indexes for ( $i = 0 ; $i < @messages ; $i++ ) { #print "New Message--\n"; for ( $j = 0 ; $j <= $#{$messages[$i]} ; $j++ ) { #print $messages[$i][$j]; if ( grep(/$messageID/,$messages[$i][$j]) ) { $line = $messages[$i][$j]; $indexA = index($line,"<")+1; $indexB = index($line,">") - $indexA; $stringMID = substr($line,$indexA,$indexB); $stringMID =~s/\s+//g; $stringMID =~s/\t+//g; #print $stringMID . "\n"; } elsif ( grep(/$threadID/,$messages[$i][$j]) ) { $line = $messages[$i][$j]; $indexA = index($line,"Thread-Index:")+13; $indexB = length($line); $stringTID = substr($line,$indexA,$indexB); $stringTID =~s/\s+//g; $stringTID =~s/\t+//g; $stringTID =~s/=+$//g; if ( length($stringTID) le 32 ) { print $stringTID . "\n"; print "Start of New Thread.\n\n"; push(@queue,$stringTID); } } if ( $stringTID && $stringMID && !$hash{$stringTID}) { #print "$stringTID -- $stringMID\n"; $hash{$stringTID} = $stringMID; } } } ## Follow all root Thread-Indexes down to find parent ## and modify message with In-Reply-To: entry while (@queue) { my $item = shift(@queue); for ( $i = 0 ; $i < @messages ; $i++ ) { $modifyB = 0; #print "New Message--\n"; for ( $j = 0 ; $j <= $#{$messages[$i]} ; $j++ ) { #print $messages[$i][$j]; if ( grep(/$threadID/,$messages[$i][$j]) ) { $line = $messages[$i][$j]; $indexA = index($line,"Thread-Index:")+13; $indexB = length($line); $stringTID = substr($line,$indexA,$indexB); $stringTID =~s/\s+//g; $stringTID =~s/\t+//g; $stringTID =~s/=+$//g; if ( index($stringTID,$item) ne -1 ) { if ( length($stringTID) - length($item) le 8 && length($stringTID) - length($item) ge 5 ) { #print "DD: " . $item . "\nDD: " . $stringTID . "\n\n"; print $stringTID . "\n"; print "Parent Thread is: \n$item \n$hash{$item}\n"; push(@queue,$stringTID); for ( $a = 0 ; $a <= $#{$messages[$i]} ; $a++ ) { if ( grep(/$inreply/,$messages[$i][$a]) ) { $modifyB = 1; } } if ( $modifyB eq 0 ) { print "Modifying..\n"; $messages[$i][$j] = $line . "In-Reply-To: <$hash{$item}>\n"; #print $messages[$i][$j]; } else { print "Already Modified\n"; } print "\n"; } } } } } # end for } # end while ## Write data back out to file open(DATA, ">$filename") ; my $oldHandle = select(DATA); for ( $i = 0 ; $i < @messages ; $i++ ) { for ( $j = 0 ; $j <= $#{$messages[$i]} ; $j++ ) { print $messages[$i][$j]; } } select($oldHandle); close DATA; -----Original Message----- From: Earl Hood [mailto:[EMAIL PROTECTED] Sent: Saturday, July 26, 2003 10:32 AM To: [EMAIL PROTECTED] Subject: Re: Exchange Server with Mhonarc ... On July 21, 2003 at 17:49, Ed Dunn wrote: > I received an answer to my last question about using microsoft exchange with > mhonarc. The link below describes that it works in pop3 mode. Is this the onl > y mode it works in? > http://www.mhonarc.org/archive/html/mhonarc-users/2003-06/msg00005.html See <http://mango.human.cornell.edu/kens/MoreFAQ.html#Convert>, which is cited in the MHonArc FAQ, <http://www.mhonarc.org/MHonArc/doc/faq/envs.html#otherformats>. > I'm not sure if this the appropriate forum, but does anyone know how to web e > nable exchange public folders for crawling by search engines? This is an Exchange-specific question, so this is the wrong forum. --ewh --------------------------------------------------------------------- To sign-off this list, send email to [EMAIL PROTECTED] with the message text UNSUBSCRIBE MHONARC-USERS --------------------------------------------------------------------- To sign-off this list, send email to [EMAIL PROTECTED] with the message text UNSUBSCRIBE MHONARC-USERS