🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.readers
Article #28434

Re: Need help setting up a news-filter ('trnkill'?)

#28434
From: Kevin Martin
Date: Mon, 16 Dec 1996 00:00
111 lines
4918 bytes
In article <32b30f3a20bb286@sn.no>,
   hallvart@sn.no (Hallvard Tangeraas) wrote:
>I really didn't understand much of that explanation about the 'trnkill'
>script, but I did a little check on my system and found an error...
>
>That is, using "trace" I found out that the path which the script is
>calling is incorrect with my UNIX setup:

That shouldn't matter, as long as trn (lowercase, please!) starts 
when you type "trn" at the command prompt.  If typing "trn" doesn't 
start trn, then you have to fix your $PATH so that it includes the 
true location of trn.

Okay, let's beat this thing once and for all.  Here's the entire 
script, and my (non-executable) comments are indented:

#!/bin/sh

   This means that it's a shell script, which will run in the 
   context of "sh", the Bourne shell, regardless of what shell
   you use by default.  The next few lines are comments...

# trnkill - shell script to apply trn KILL files in the background
# 14 Mar 89  created for rn by Jim Olsen <olsen@XN.LL.MIT.EDU>
# 10 Sep 93  modified for trn 3 (or 2) by Wayne Davison 
# <davison@borland.com>
# 16 Nov 94  complete rewrite; via e-mail from Chin Huang 
# <cthuang@io.sys>
#
# Options: -d   debug mode -- you see all gory action as it happens.
#

  This next comment explains EXACTLY what the script does:

# Visit all newsgroups (if trn asks about anything else, just say no)

  Now it's going to create some "symbols" and write a few lines
  out to your /tmp directory, using your process ID to give the
  resulting temporary file a unique name:

export TRNINIT TRNMACRO RNMACRO
TRNINIT='-q -s -T -t -x +X'
TRNMACRO=/tmp/trnkill$$
# support for trn 2.x
RNMACRO=$TRNMACRO

   It's going to exit and remove the temporary file on any of
   a number of possible conditions....

trap 'rm -f $TRNMACRO; exit' 1 2 3 15

   Here is where it creates the three-line temporary file:

cat >$TRNMACRO <<'EOF'
z  %(%m=[nf]?.q^J:n)^(z^)
^m ^(z^)
^j ^(z^)
EOF

   These three lines say (in trn talk) "run some trn commands
   when the user presses the 'z' key."  That's what a macro is,
   just some pre-recorded commands.  All THESE trn commands do
   is open the next subscribed group and then 'q'uit.  Repeat
   until you run out of groups, at which point the run ends.

   The heart of the matter is the line "echo 'z' | trn" which 
   runs trn AND SENDS IT THE 'z' KEY.  Note that the script
   does not specify that directory you had in your trace --
   so if you've diddled with the script to include your home
   directory or something, put it back the way it was:

if test X$1 = X-d; then
        echo "z" | trn
else
        echo "z" | trn >/dev/null 2>&1
fi

   Clean up by deleting the temporary file, and we're done:
rm -f $TRNMACRO
exit 0

That's all there is to it.  The "magic" is entirely a question
of what trn KILL files you have created.  If you don't have any,
then running the above will not do anything.  If you do, they
will be applied (the global KILL file will apply to all the
groups you read, and the group-specific ones will apply to the
appropriate group).

>And.... I don't use TRN, but TIN. I've barely tried TRN, and if I can 
>avoid learning another totally new program to me just in order to do 
>this filtering thing I'd be most grateful.

Sorry, tin doesn't know anything about trn's macro language or KILL 
files.  You HAVE to use trn to do this.

I've run tin a couple of times when trn blew up on an invalid article,
and they seem to be honoring the same .newsrc file (for the benefit of 
lurkers with even less experience than you, the .newsrc file lists the 
groups to which you subscribe and the article-numbers you've already 
seen; it's how a newsreader knows not to show you the same stuff twice). 
So if you run trnkill it should clean up things for tin -- and for uqwk.

But you HAVE to create the KILL files using trn's syntax in order for 
this to work.  Make up your mind to put in a bit of effort, and we'll be 
happy to help you as much as we can.  You have to hold up your end of 
the load, though.  You don't have to be a trn wizard to write a few 
simple KILL files.  Just read the FAQ's that have already been pointed 
out.  The time you invest doing this will be repaid very quickly.

Technical Details
Message-ID: <593pjm$rnc@spruce.citicorp.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.mbox.zip!not-for-mail
References: <32b30f3a20bb286@sn.no>

Show Full Headers
Complete Article Headers
Message-ID: <593pjm$rnc@spruce.citicorp.com>
Subject: Re: Need help setting up a news-filter ('trnkill'?)
Date: Mon, 16 Dec 1996 00:00:00 +0000
From: cannon@Nic.com (Kevin Martin)
References: <32b30f3a20bb286@sn.no>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.mbox.zip!not-for-mail
X-Deja-AN: 204547833
Distribution: citi
Organization: Brass Cannon Consulting
Newsgroups: news.software.readers