#!/usr/bin/env perl # # Pamela - Print Administrative Mail Logs (PAML) # # This script prints administrative logs, assuming that they # are kept in a file in Unix mailbox format. The subject, date # and sender are extracted from the headers and printed at the # begining of a message, then the message. Nothing more. # This is suitable for making hardcopies of logs (but will also # make a nice summary of e-mail folders). # # Eric Myers 29 October 1997 # Department of Physics, University of Michigan, Ann Arbor, MI USA # @(#) $Revision: 1.7 $ $Date: 1998/10/12 17:24:07 $ ######################################################################## $TITLE = "System Administrative Log"; $ORGANIZATION = $ENV{"ORGANIZATION"}; # For safety: $ENV{"PATH"} = "/usr/local/adm /usr/local/bin /bin /usr/bin /usr/etc "; $/ = "\nFrom " ; # Break at message breaks, not lines while (<>) { # Read next message ## remove initial (or trailing) "From " s/^From // ; s/\nFrom $// ; ## First line has name/date. s/^(.*)\n// && ( $firstline = "From " . $1); ( $from, $date ) = $firstline =~ /From\s*(\S+)\s*(.*)/; $from =~ s/(\w+[@]\w*)\..*umich.edu/\1/ ; # strip local names ## Headers up to blank line, then text follows (perhaps several paragraphs) ($headers, @pars) = split(/\n\n/); $text = join("\n\n", @pars); $text =~ s/\n\n\n/\n\n/; # suppress multiple blank lines $text = $text . "\n"; # make sure ends on \n $text =~ s/\n\n$/\n/; # but not two of them. ( $subject ) = $headers =~ /\nSubject:\s(.*)\n/; $SUBJ = "SUBJECT:"; $div = "========"; ## Start a new page if there is not room for this entry to get started if ( $- < 10 ) { $- = 0;} write; while ( $text =~ s/(.*)\n// ) { $line = $1; ## print "($- ) "; # DEBUG: number of lines remaining on page print " $line\n"; $---; # force new page in middle of message if ( $- <= 1 ) { $div = "(Continued...)"; if ( ! $subject ) { $SUBJ = ""; } write ; } } print "\n"; $---; } exit 0; #======================================================================* # Formats for the report #======================================================================* format STDOUT = @<<<<<<<<<<<<<<<<< $div @<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $SUBJ, $subject From: @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<< $from, $date . format STDOUT_TOP = @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Page @>> $TITLE $% @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $ORGANIZATION Date: @<<<<<<<<<<<<<<<<<<<<<<<<<<<< $date . __END__;