From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <96078614710318.tru64-unix-managers.marc@archive.invalid> From: Uwe Siodlaczek Date: Thu, 10 Jul 1997 07:22:27 +0000 To: tru64-unix-managers Subject: SUM: Mailfolder VMS -> UNIX X-MARC-Message: https://marc.info/?l=tru64-unix-managers&m=96078614710318 Thank you to everyone who responded! Jim Belonis rnfrank@pierce.llnl.gov Dave Greenwood The first answer came from Jim Belonis, who sent me a perl-script doing this job fine. I make two minor changes to get it working with Perl 5 and include it after my signature. Uwe Siodlaczek ----------------------- CUT --------------------------- #!/pub/bin/perl -i.orig 'di'; 'ig00'; # # Fixmail - convert VMS mail files to Unix form. # To save a VMS e-mail folder in a usable text file... # inside of VMS MAIL # EXTRACT/ALL/MAIL filename # # N.B.: does in-place editing. # $/ = "\f\nFrom" ; # Break at messages, not lines $frompat = '^:\t(\S+)' # sender address . ' +(".+")?' # sender name . ' *(\d+)-(\w{3})-(\d{2}(\d{2}))' # dd-mm-yyyy date . ' +(\d+:\d+)\.?\d*' # hh:mm.xx time . " *\n" ; while (<>) # Read next message { s|$/$|\n| ; # Drop start of next message if ($. == 1) # First message in input file? { s/^\s*From// ; # Handle missing initial \f\n next if ! /\S/ ; # Handle leading \f\nFrom } $mesg++ ; # Count messages if (($addr, $name, $day, $mon, $year, $yr, $time) = (/$frompat/)) { s/^.*\n// ; # drop From: line (($to) = /^To:\t(\S+) */) && s/^.*\n// ; # drop To: line (($cc) = /^CC:\t(.*)/) && s/^.*\n// ; # drop CC: line (($subj) = /^Subj:\t(.*)/) && s/^.*\n// ; # drop Subj: line $name =~ s/^"(.+)"$/$1/ ; # drop quotes $addr =~ s/^IN%"([^"]+)"$/$1/i ; # fix IN% $addr =~ s/^ARPA%"([^"]+)"$/$1/i ; # fix ARPA% $addr =~ s/^JNET%"([^"]+)"$/$1.bitnet/i ; # fix JNET% $addr =~ s/^UUCP%"([^"]+)"$/$1.uucp/i ; # fix UUCP% $addr =~ s/^BITNET%"([^"]+)"$/$1/i ; # fix BITNET% $addr =~ s/(\S+)::(\S+)/$2\@$1/ ; # fix VMS hosts $day = sprintf ("%2d", $day) ; # pad date $wkdy = &weekday ($day, $mon, $year) ; print "From \L$addr\E $wkdy \u\L$mon $day $time $year\n" ; print "From: $name <\L$addr\E>\n" if $name ; print "Subject: $subj\n" if $subj ; print "To: \L$to\n" if $to ; print "Date: $wkdy, $day \u\L$mon\E $yr $time\n" ; print "Cc: $cc\n" if $cc ; print ; next ; } /^(.*)/ && warn ("\nSkipping garbled message \#$mesg:\n\tFrom$1\n") ; } continue { close (ARGV) if (eof) ; # Reset line numbers if multiple files } sub weekday { local ($day, $mon, $year) = @_ ; %month = ( jan, 0, feb, 1, mar, 2, apr, 3, may, 4, jun, 5, jul, 6, aug, 7, sep, 8, oct, 9, nov, 10, dec, 11 ) ; @offset = ( 0, 3, 3, 6, 1, 4, 6, 2, 5, 0, 3, 5 ) ; @wkday = ( Mon, Tue, Wed, Thu, Fri, Sat, Sun ) ; $m = $month {"\L$mon"} ; # month number $y = $year - ($year % 4) ; # previous leapyear $leap = $year == $y ; # current leapyear $weekday = 5 ; # for 1/1/2000 $weekday += 5 * ($y - 2000) / 4 ; # for 1/1/$y $weekday += ($year - $y) + !$leap ; # for 1/1/$year $weekday += $offset [$m] + ($leap && ($m > 1)) ; # for $m/1/$year $weekday += $day - 1 ; # for $m/$day/$year $wkday [$weekday % 7] ; } ######################## .00; 'di .nr nl 0-1 .nr % 0 '; __END__ .TH FIXMAIL 1 "November 30, 1993" .AT 3 .SH NAME fixmail \- convert VMS mail files to Unix form .SH SYNOPSIS .B fixmail file1 file2 ... .SH DESCRIPTION .I Fixmail converts VMS mail files to conventional Unix form. The input files .I must be plain text files as produced by the VMS Mail 'extract' command; not binary indexed VMS mail files. .I Fixmail edits the header lines of each message, and attempts to translate the sender's address to an acceptable Internet form. A backup copy of the original file is saved (with .orig appended to its name). .SH AUTHOR Laurence G. Yaffe (lgy@phys.washington.edu) .SH DIAGNOSTICS Complains about garbled From: lines which it does not recognize. .SH BUGS May not be able to translate all VMS addresses into a useful (reply-able) form.