Xref: utzoo news.sysadmin:3459 news.misc:5826 news.software.nntp:997 Path: utzoo!utstat!news-server.csri.toronto.edu!cs.utexas.edu!usc!apple!amdahl!krs From: krs@uts.amdahl.com (Kris Stephens [Hail Eris!]) Newsgroups: news.sysadmin,news.misc,news.software.nntp Subject: Re: mailing lists -> newsgroups Message-ID: Date: 19 Dec 90 18:59:06 GMT References: Reply-To: krs@amdahl.uts.amdahl.com (Kris Stephens [Hail Eris!]) Distribution: news Organization: Amdahl Corporation, Sunnyvale CA Lines: 114 In article meyer@cambium.uoregon.edu (David M. Meyer) writes: > Does anyone have a script that they like for injecting > news from a mailing list (e.g., an alias) into a local > news group (i.e., that does the "right" thing with > headers, subject lines, etc)? > > Thanks, > Dave In its simplest form, all the program needs to do is strip the leading 'From ' header (without a colon) and feed it into inews -h... -- # Replace "newslist" with the phantom username that's on the mailing list # Replace "news.group" with the newsgroup name aliases: (for sendmail) newslist:"|/bin/sed 1d | /usr/lib/news/inews -h -n news.group" aliases: (for smail) newslist:"|/bin/sed 1d | /usr/lib/news/inews -h -f\"$SENDER\" -n news.group" -- I tend to lean a little harder on it by stripping out a few other headers, and thus use awk instead of sed. If the awk script is in /usr/lib/news... -- # Replace "newslist" with the phantom username that's on the mailing list # Replace "news.group" with the newsgroup name aliases: (for sendmail) newslist:"|/bin/awk -f /usr/lib/news/mail2news.awk | /usr/lib/news/inews -h -n news.group" aliases: (for smail) newslist:"|/bin/awk -f /usr/lib/news/mail2news.awk | /usr/lib/news/inews -h -f\"$SENDER\" -n news.group" -- -- cut into mail2news.awk -- # %W% %G% %U% # # mail2news.awk -- a utility to handle the headers in a mailfile for # posting as news # BEGIN { mysite = "your_uucp_node_name_here" # Tailor this line!! nuke[1] = "[Tt][Oo]:" nuke[2] = "[Cc][Cc]:" nuke[3] = "[Bb][Cc][Cc]:" nuke[4] = "[Rr][Ee][Cc][Ee][Ii][Vv][Ee][Dd]" nuke[5] = "[Ss][Tt][Aa][Tt][Uu][Ss]:" nuke[6] = ".*[Mm][Aa][Ii][Ll][Ee][Rr]" nuke[7] = "[Dd][Aa][Tt][Ee]:" nukes = 7 cont_nuke = 0 inheader = 1 # Until we get a null line } # # Once we're out of the header, just print the lines # inheader == 0 { print next } # # End of header? # $0 == "" { inheader = 0 print next } # # Delete mail's leading 'From ' header # NR == 1 && match($0, "[Ff][Rr][Oo][Mm] ") == 1 { print "Path:", mysite "!nobody" next } # # Continuation of a nuked header? # cont_nuke == 1 { first = substr($0, 1, 1) if ( first == " " || first == "\t" ) { next # Skip it -- it's a continuation } cont_nuke = 0 # Otherwise, turn off cont_nuke flag } # # Lines to cut? # { for ( i = 1; i <= nukes; i++ ) { if ( match($1, nuke[i]) == 1 ) { cont_nuke = 1 # Set cont_nuke flag for next line next # Don't print this one } } print } -- cut into mail2news.awk -- ...Kris -- Kristopher Stephens, | (408-746-6047) | krs@uts.amdahl.com | KC6DFS Amdahl Corporation | | | [The opinions expressed above are mine, solely, and do not ] [necessarily reflect the opinions or policies of Amdahl Corp. ]