Xref: utzoo news.sysadmin:3348 news.software.b:6071 news.misc:5603 Path: utzoo!utstat!news-server.csri.toronto.edu!umich!tut.cis.ohio-state.edu!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!abcfd20.larc.nasa.gov!tadguy From: tadguy@abcfd01.larc.nasa.gov (Tad Guy) Newsgroups: news.sysadmin,news.software.b,news.misc Subject: Re: a Bnews-recnews equiv for Cnews Message-ID: Date: 28 Oct 90 15:11:42 GMT References: <67940@iuvax.cs.indiana.edu> Sender: news@abcfd20.larc.nasa.gov (USENET File Owner) Organization: NASA Langley Research Center, Hampton, VA Lines: 115 In-Reply-To: royle@iuvax.cs.indiana.edu's message of 28 Oct 90 06:06:01 GMT 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 '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 = ''; ; ) { 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 ; 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