🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.admin
Article #3985

capturing local posts

#3985
From: Brendan Kehoe
Date: Fri, 08 May 1992 17:33
113 lines
4720 bytes
I was recently asked for a copy of this, and thought it might be of
general interest.  PLEASE, don't start on the politics of using
something like this---I just wrote it. :-)

It will take any post generated from a local site (within 1 hop) and
place it in a file, with the subject line

	Subject: [widener.misc] cable

where the bracketed part is the original newsgroup the post appeared
in.  By default, it will get posted to a newsgroup of your choice.  If
you'd rather log into a file, change the line
	open(INEWS, "|/usr/lib/news/inews -h") ...
to
	open(INEWS, ">>/some/filename") ...

It will place the original Message-ID:, Distribution:, and
NNTP-Posting-Host: headers into X-'d versions of themselves.

Bug fixes & enhancements (and perl cleaning) welcome.

-- cut --
#!/bin/perl --   #  Dis be -*-Perl-*-
#
# capture v1.0 - 08/15/91 - by Brendan Kehoe (brendan@cs.widener.edu)
#
# Intended to capture outgoing posts from the local system and put them
#  in a local group, for debugging purposes.  The post will show up with
#  a Subject: line of:
#              Subject: [original.news.group] The Original Subject
#
# Your sys file for CNews should contain:
#	SnaG:all,!widener.outgoing/all:FL:/usr/lib/newsbin/capture %s
# For INN, newsfeeds should have:
#	SnaG:*,!widener.outgoing:Tp,H2:/usr/lib/newsbin/capture %s
#
# Replace !widener.outgoing with the name of the group these posts will
#  be going to.  (If you don't, it'll loop itself to the Happy Home.)
#
# (Note, if you have anything like a mail gateway that posts locally to your
#  machine, make sure they're not in the sys line [it'd be a waste].  For
#  example, I have     *,!widener.mail.*   in my newsfeeds line cuz the
#  widener.mail hierarchy is made up of mailing lists gatewayed into 
#  newsgroups.)

# The group to post to:
$GROUP = "widener.outgoing";

# Name to show up in the Path: header; pathhost as defined in inn.conf,
#  or what's in $NEWSCTL/whoami for CNews.
$PATHHOST = "widener";

header:
while(<>) {
    last header if /^$/;
    chop; $headers[$nh] = $_;

    /^Path:[ \t]*(.*)!(.*)!news$/ && do {
	# it happened to have two hops, but we weren't both of them.
	if ($1 ne $2) { exit 0; }
    };
    /^Newsgroups:[ \t]*(.+)$/ && do { $to = $1;
				     $headers[$nh] = "Newsgroups: $GROUP";
    };
    /^Subject:[ \t](.*)/ && do {
	$headers[$nh] = "Subject: [" . substr($to, 0,
			   (($i = index($to, ",")) > 0) ? $i : length($to)) .
	                   (($i > 0) ? " ...]" : "]") . " $1";
	$subj = 1;
    };
    /^Distribution:[ \t]*(.*)/ && do {
	$headers[$nh] = "Distribution: local";
	$headers[++$nh] = "X-Distribution: $1";
	$dist = 1; };
    /^Message-ID:[ \t]*(.*)/ && do {
	$headers[$nh] = "X-Message-ID: $1"; };
    /^NNTP-Posting-Host:[ \t]*(.*)/ && do {
	$headers[$nh] = "X-NNTP-Posting-Host: $1";
    };
    if ( /^Received:/ || /^Xref:/ || /^Date-Received:/ || /^Posted:/ ||
	/^Posting-Version:/ || /^Relay-Version:/ ) { $nh--; } # Eat these
	    
    $nh++;
}

if (! $to) { $to = "widener.missing.group";
	     $headers[$nh++] = "Newsgroups: $GROUP";
}
if (! $subj) {
	$headers[$nh] = "Subject: [" . substr($to, 0,
			(($i = index($to, ",")) > 0) ? $i : length($to)) .
	                ($i > 0) ? " ..." : "" . "] (No subject)";
}
if (! $dist) { $headers[$nh++] = "Distribution: local"; }

open(INEWS, "|/usr/lib/news/inews -h") || die "Can't open inews: $!\n";
foreach $head (@headers) { print INEWS "$head\n"; }
while (<>) { print INEWS $_; };
close INEWS;
print "Error: $!\n" if $?;
-- cut --

--
Brendan Kehoe, Sun Network Manager                      brendan@cs.widener.edu
Widener University                                                 Chester, PA
    In action-oriented shows, TV cops fire their guns in almost every episode;
       in Chicago, the average police officer fires a gun once every 27 years.
--
Brendan Kehoe, Sun Network Manager                      brendan@cs.widener.edu
Widener University                                                 Chester, PA
    In action-oriented shows, TV cops fire their guns in almost every episode;
       in Chicago, the average police officer fires a gun once every 27 years.
Technical Details
Message-ID: <BRENDAN.92May8173355@betty.cs.widener.edu>
Path: arc1-ca.pugleaf.net!wupost!darwin.sura.net!gatech!news.byu.edu!eff!widener!widener!brendan

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!wupost!darwin.sura.net!gatech!news.byu.edu!eff!widener!widener!brendan
From: brendan@cs.widener.edu (Brendan Kehoe)
Newsgroups: news.admin,alt.sources
Subject: capturing local posts
Date: 8 May 92 17:33:55
Organization: Widener University Department of Computer Science, Chester, PA
Lines: 113
Distribution: world
Message-ID: <BRENDAN.92May8173355@betty.cs.widener.edu>
Reply-To: brendan@cs.widener.edu
NNTP-Posting-Host: betty.cs.widener.edu