🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.mail.mh
Article #1944

Re: Automatically Fcc'ing the message's recipient

#1944
From: Tom Christiansen
Date: Thu, 14 Dec 1989 16:08
69 lines
1980 bytes
Yarg!  Due to the undocumented '-idanno N' trailing args to post, 
this didn't work on annotated messages.  This seems to fix it.  
I've spiffed up the error messages, moved the pat to post to 
the top so you can get at it easily, and made the thing background
itself for speed.

--tom

#!/usr/bin/perl

exit if fork;

@newargv = ( '/usr/local/mh/lib/post', @ARGV );

if ( $ARGV[$#ARGV - 1] eq '-idanno' ) {
    $file = $ARGV[$#ARGV - 2];
} else {
    $file = $ARGV[$#ARGV];
}


$tmp = "$file.$$";

open (file, "<$file") || die "can't read $file, argv was $0 @ARGV: $!";

open (tmp, ">$tmp")  || die "can't write $tmp, argv was $0 @ARGV: $!";

select(tmp);


while (<file>) {
    last if /^-*$/;
    if (/^((resent-)?(to|b?cc)):\s*(.+)/i) {
	$header = $1;
	do parse($4);
    } elsif (/^\s+(.*)/ && $header) {
	do parse($1);
    } else {
	$header = '';
    } 
    print;
} 

print "Fcc: ",  join(', ', @fccs), "\n" if $#fccs >= 0;
print "\n";
print while <file>;

close file;
close tmp;
rename($tmp,$file);

exec @newargv;

sub parse {
     local($_) = @_;

     for (split(/\s*,\s*/)) {
	s/.*<([^>]+)>.*/$1/;
	s/@.*//;
	s/.*!//;
	s/\(.*\)//;
	s/\s//g;
	push(@fccs,'+'.$_) unless $seen{$_}++;
     } 
} 

    Tom Christiansen                       {uunet,uiucdcs,sun}!convex!tchrist 
    Convex Computer Corporation                            tchrist@convex.COM
		 "EMACS belongs in <sys/errno.h>: Editor too big!"
Technical Details
Message-ID: <3951@convex.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!uunet!convex!tchrist@convex.COM
References: <3943@convex.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!uunet!convex!tchrist@convex.COM
From: tchrist@convex.COM (Tom Christiansen)
Newsgroups: comp.mail.mh
Subject: Re: Automatically Fcc'ing the message's recipient
Keywords: fcc perl postproc
Message-ID: <3951@convex.UUCP>
Date: 14 Dec 89 16:08:52 GMT
References: <3943@convex.UUCP>
Sender: news@convex.UUCP
Reply-To: tchrist@convex.COM (Tom Christiansen)
Organization: CONVEX Software Development, Richardson, TX
Lines: 69