tadguy@abcfd01.larc.nasa.gov (Tad Guy) (10/28/90)
In article <67940@iuvax.cs.indiana.edu> royle@iuvax.cs.indiana.edu (Keenan Royle) writes: > Does someone have this hack implimented? Or can give some pointers? I didn't find anything suitable in the CNEWS distribution, so I wrote my own in PERL. Care is taken to generate a somewhat meaningful Path: line, and to undo some common forms of address rot (most of the code is reused from my never completed archive server). Use it in aliases like this: in-sun-managers:"|/usr/lib/news/receive mail.sun-managers" You can even cross-post mailing lists to multiple groups, though I don't know why I did that other than it was easy... ...tad #!/bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of shell archive." # Contents: receive # Wrapped by tadguy@abcfd20 on Sun Oct 28 09:05:01 1990 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'receive' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'receive'\" else echo shar: Extracting \"'receive'\" \(1509 characters\) sed "s/^X//" >'receive' <<'END_OF_FILE' X#!/usr/bin/perl X# X# Prepare a mail message for posting to a newsgroup. X# Really, just remove any unwanted headers, preapprove it, and feed it to inews X# X$INEWS = '| /usr/lib/newsbin/inews -p'; X$APPROVE= 'usenet@news.larc.nasa.gov'; X Xdie "Usage: receive group ...\n" if $#ARGV == -1; X X%keep = ('from', 1, X 'subject', 1, X 'date', 1, X 'message-id', 1, X 'sender', 1, X 'organization',1, X 'lines', 1 X); X Xsub canonicalize { X local($addr) = @_; X $addr = $1 if $addr =~ /\<(.*)\>/; X $addr = $1.$2 while $addr =~ /^(.*)\(.*\)(.*)$/; X $addr = $1.$2 while $addr =~ /^(.*)".*"(.*)$/; X $addr = $1 if $addr =~ /\s*(\S+)\s*/; X $addr =~ y/A-Z/a-z/; X X $addr = "$1@$2.BITNET" if $addr =~ /^(\S+)%(\S+)\.bitnet@/i; X $addr = "$1@$2" if $addr =~ /^(\S+)%(\S+)@relay.cs.net$/i; X $addr; X} X Xsub munge { X local($line) = @_; X local($head,$body); X X $line =~ /^([^:]+):\s*(.+)$/; X $head = $1; $body = $2; X $head =~ tr/A-Z/a-z/; X X $from = &canonicalize($body) if $head eq 'from'; X X print INEWS "$line\n" if $keep{$head}; X} X Xdie "$INEWS: $!\n" unless open(INEWS,$INEWS); X Xprint INEWS "Newsgroups: ".join(',',@ARGV)."\n"; X Xfor ( $line = ''; <STDIN>; ) { X chop; X last if /^$/; X X if ( /^\S/ && $line ne '' ) { X &munge($line); X $line = ''; X } X X $line .= $_; X} X&munge($line) if $line ne ''; X Xif ( $from =~ /(.+)@(.+)/ ) { X print INEWS "Path: $2!$1\n"; X} else { X print INEWS "Path: $from\n"; X} X Xprint INEWS "Approved: $APPROVE\n\n"; X Xprint INEWS <STDIN>; X Xclose(INEWS); X Xexit 0 END_OF_FILE if test 1509 -ne `wc -c <'receive'`; then echo shar: \"'receive'\" unpacked with wrong size! fi chmod +x 'receive' # end of 'receive' fi echo shar: End of shell archive. exit 0
rsalz@bbn.com (Rich Salz) (11/02/90)
In <TADGUY.90Oct28091142@abi2.larc.nasa.gov> tadguy@abcfd01.larc.nasa.gov (Tad Guy) writes: >X $addr = "$1@$2" if $addr =~ /^(\S+)%(\S+)@relay.cs.net$/i; It's amazing what sticks around. CSNET has been using full domain names for quite some time, now. Sheesh, someone transliterates an Fair's AWK script... ;-) /r$ -- Please send comp.sources.unix-related mail to rsalz@uunet.uu.net. Use a domain-based address or give alternate paths, or you may lose out.