🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: news.software.readers
8 messages
8 total messages Started by Peter Janes Mon, 04 Jul 1994 23:31
Cron-able news saver?
#9808
Author: Peter Janes
Date: Mon, 04 Jul 1994 23:31
21 lines
1784 bytes
I'm trying to automatically save particular articles from newsgroups.
Originally it appeared 'trn' plus a script file to run it would work; it
turns out that 'trn' doesn't run correctly without a tty.  (I've tried using
'expect' to provide a pty with no luck.)  'slurp' was suggested, but as far
as I can tell, it has no selection facility--it just sucks up all the
articles in the newsgroup it's pointed at.

So, net and news gurus, is there anything that will do what I need, running
on a UNIX SVR4 platform (that is, a program that can run from cron,
selectively saving articles with a particular pattern or particular patterns
in the headers or message bodies)?  Ideally it would use a format similar to
a KILL file, e.g.
	/foo@bar/f:s FooPosts:j

Thanks for any help or information,
PEJ
-- 
Peter Edward Janes                // | "I always wondered how Tom Waits would
 (pejanes@descartes.uwaterloo.ca)//  |  sing Greensleeves...."
   Certified Amiga Developer   \X/   |    --Loreena McKennitt, _The Visit_
    ** SUPPORT CANADIAN MUSIC **     |      (liner notes for Greensleeves)
Re: Cron-able news saver?
#9833
Author: Steven King, Software Archaeolog...
Date: Tue, 05 Jul 1994 16:28
40 lines
2700 bytes
pejanes@undergrad.math.uwaterloo.ca (Peter Janes) publicly declared:
>I'm trying to automatically save particular articles from newsgroups.
>Originally it appeared 'trn' plus a script file to run it would work; it
>turns out that 'trn' doesn't run correctly without a tty.  (I've tried using
>'expect' to provide a pty with no luck.)  'slurp' was suggested, but as far
>as I can tell, it has no selection facility--it just sucks up all the
>articles in the newsgroup it's pointed at.

Try running the following script from cron, which will throw trn into
batch mode to process your KILL files.  Just put the appropriate
commands in the KILL files and all will be right with the world.

---=== Cut Here ===--- ---=== Cut Here ===--- ---=== Cut Here ===---
#!/bin/sh
# trnkill - shell script to apply trn KILL files in the background
# 14 Mar 89  created by Jim Olsen <olsen@XN.LL.MIT.EDU>
# 10 Sep 93  modified for trn 3 (or 2) by Wayne Davison <davison@borland.com>
# Options: -d	debug mode -- you see all gory action as it happens.

# Visit all newsgroups (if trn asks about anything else, just say no)
export TRNINIT TRNMACRO RNMACRO
TRNINIT='-q -s -T -t -x +X'
TRNMACRO=/tmp/trnkill$$
# support for trn 2.x
RNMACRO=$TRNMACRO
trap 'rm -f $TRNMACRO; exit' 1 2 3 15
echo "z %(%m=[nf]?.q^M:n)^(z^)" > $TRNMACRO
if test X$1 = X-d; then
	echo "z" | trn
else
	echo "z" | trn >/dev/null 2>&1
fi
rm -f $TRNMACRO
exit 0
---=== Cut Here ===--- ---=== Cut Here ===--- ---=== Cut Here ===---

-- 
----------------------------------------------<Steven King, king@cig.mot.com>--
Nothing is more conducive to peace of mind than not having any opinions at all.
                                      (Georg Christoph Lichtenberg [1742-1799])
Re: Cron-able news saver? (related question)
#9880
Author: Peter Janes
Date: Thu, 07 Jul 1994 02:39
25 lines
2029 bytes
In article <1994Jul6.195017.26518@kocrsv01.delcoelect.com>,
Andy Tenka <c22at@kocrsv01.delcoelect.com> wrote:
>I tried running the trnkill from the command line, and somehow it gets
>Would the trn gods out there tell me what the hell I am doing wrong with the
>KILL file?  The following is the script of what happens when I run trnkill.

I'm by no means a trn god, but I had trouble with the script as supplied,
too.  (I was the original poster, BTW, and this was the script I mentioned.)
It appears that the ^M doesn't work correctly on some versions of trn (no
specifics, other than version 3.2 here).  If replaced with \n, it works fine
when started interactively or backgrounded with & or ^Z (but still not from
a cron).

>My final goal is to have trnkill to e-mail me only the articles of
>interest to me from each newsgroup.  Many billion thanks in advance.

Hope the "fix" helps.

PEJ

-- 
Peter Edward Janes                // | "I always wondered how Tom Waits would
 (pejanes@descartes.uwaterloo.ca)//  |  sing Greensleeves...."
   Certified Amiga Developer   \X/   |    --Loreena McKennitt, _The Visit_
    ** SUPPORT CANADIAN MUSIC **     |      (liner notes for Greensleeves)
Re: Cron-able news saver? (related question)
#9890
Author: Sridhar Venkataraman
Date: Thu, 07 Jul 1994 13:48
27 lines
2114 bytes
pejanes@undergrad.math.uwaterloo.ca (Peter Janes) writes:

| I'm by no means a trn god, but I had trouble with the script as supplied,
| too.  (I was the original poster, BTW, and this was the script I mentioned.)
| It appears that the ^M doesn't work correctly on some versions of trn (no
| specifics, other than version 3.2 here).  If replaced with \n, it works fine
| when started interactively or backgrounded with & or ^Z (but still not from
| a cron).

You could use ^j (caret followed by j) too.

I am pretty sure that the cron problem is specific to your machine/OS
since I haven't seen a problem running 'trnkill' from cron using the old 
rn 4.*, trn 2.*, all through the trn 3-beta until v3.5 where it stands now.
There was a slight problem during the beta phase when Wayne added code
for xterm mouse handling but he sent out a patch after it was found.
Even during that time, I could run trnkill assigning TERM to null.

The infinite loop problem at the "End of Newsgroups" prompt faced by
the user was probably not due to Ctrl-M IMO, but due to the fact that
there was no difference between "End of Newsgroups" prompt and the
newsgroup selection prompt in earlier versions (2.* ?).  
Both had %m=n  But now %m=f for the former and %m=n for the latter.   
He was probably using a older script with a newer trn (v3.*).  Well, 
it is only a guess. :-)

Sridhar.
Re: Cron-able news saver? (related question)
#9893
Author: Sridhar Venkataraman
Date: Thu, 07 Jul 1994 14:20
9 lines
1006 bytes
sridhar@asuvax.eas.asu.edu (Sridhar Venkataraman) writes:

| The infinite loop problem at the "End of Newsgroups" prompt faced by
| the user was probably not due to Ctrl-M IMO, 

Mea Culpa.  I seemed to have misread the posting! But keep in mind
that this is a possible future problem. :-)

Sridhar.
Re: Cron-able news saver? (related question)
#9892
Author: Steven King, Software Archaeolog...
Date: Thu, 07 Jul 1994 14:25
56 lines
3358 bytes
pejanes@undergrad.math.uwaterloo.ca (Peter Janes) publicly declared:
>I'm by no means a trn god, but I had trouble with the script as supplied,
>too.  (I was the original poster, BTW, and this was the script I mentioned.)
>It appears that the ^M doesn't work correctly on some versions of trn (no
>specifics, other than version 3.2 here).  If replaced with \n, it works fine
>when started interactively or backgrounded with & or ^Z (but still not from
>a cron).

And I'm the one who posted this particular 'trnkill' script.  It seems
there was an error on my part.  That "^M" wasn't really a control-M, but
the two characters "^" and "M".  Probably an artifact of cutting and
pasting at some point in the script's life.  I apologize.  I made the
correction Peter suggested and replaced the "^M" with the "\n" token.

I also apologize that the script didn't run the way I thought it would.
Even after this fix, Peter is exactly right.  It runs from the command
line, but doesn't run when invoked from cron.  I get "13499 Abort - core
dumped" when I try.

Wayne, if you're interested I can ship you the core or any other data
you'd like.  This is a Sparc running SunOS 4.3.1; the version of trn is:

    @(#)$Id: trn.c,v 3.0 1991/11/22 00:14:59 davison Trn $
    Version: 3.5 
    Send bug reports to davison@borland.com

For everyone else, here's the corrected version of 'trnkill', with the
"^M" replaced.

---=== Cut Here ===---  ---=== Cut Here ===---  ---=== Cut Here ===---
#!/bin/sh
# trnkill - shell script to apply trn KILL files in the background
# 14 Mar 89  created by Jim Olsen <olsen@XN.LL.MIT.EDU>
# 10 Sep 93  modified for trn 3 (or 2) by Wayne Davison <davison@borland.com>
# Options: -d	debug mode -- you see all gory action as it happens.

# Visit all newsgroups (if trn asks about anything else, just say no)
export TRNINIT TRNMACRO RNMACRO
TRNINIT='-q -s -T -t -x +X'
TRNMACRO=/tmp/trnkill$$
# support for trn 2.x
RNMACRO=$TRNMACRO
trap 'rm -f $TRNMACRO; exit' 1 2 3 15
echo "z %(%m=[nf]?.q\n:n)^(z^)" > $TRNMACRO
if test X$1 = X-d; then
	echo "z" | trn
else
	echo "z" | trn >/dev/null 2>&1
fi
rm -f $TRNMACRO
exit 0
---=== Cut Here ===---  ---=== Cut Here ===---  ---=== Cut Here ===---

-- 
----------------------------------------------<Steven King, king@cig.mot.com>--
2 + 2 = 5  for sufficiently large values of 2.
Re: Cron-able news saver? (related question)
#9922
Author: Wayne Davison
Date: Fri, 08 Jul 1994 06:30
34 lines
1858 bytes
According to Steven King, Software Archaeologist <king@wildebeest.cig.mot.com>:
> I also apologize that the script didn't run the way I thought it would.
> Even after this fix, Peter is exactly right.  It runs from the command
> line, but doesn't run when invoked from cron.  I get "13499 Abort - core
> dumped" when I try.

I think that this is because some Configurations of trn (not all) attempt
to open /dev/tty to turn on the no-delay input.  Try this patch (untested):

Index:term.c
@@ -149,10 +149,13 @@
     /* do no delay reads on something that always gets closed on exit */
 
-    devtty = open("/dev/tty",0);
-    if (devtty < 0) {
-	printf(cantopen,"/dev/tty") FLUSH;
-	finalize(1);
+    devtty = fileno(stdin);
+    if (isatty(devtty)) {
+	devtty = open("/dev/tty",0);
+	if (devtty < 0) {
+	    printf(cantopen,"/dev/tty") FLUSH;
+	    finalize(1);
+	}
+	fcntl(devtty,F_SETFL,O_NDELAY);
     }
-    fcntl(devtty,F_SETFL,O_NDELAY);
 #endif
 #endif

and let me know if it works.  Thanks!
-- 
Wayne Davison
davison@borland.com
Re: Cron-able news saver? (related question)
#9932
Author: Steven King, Software Archaeolog...
Date: Fri, 08 Jul 1994 14:41
15 lines
1678 bytes
davison@borland.com (Wayne Davison) publicly declared:
>I think that this is because some Configurations of trn (not all) attempt
>to open /dev/tty to turn on the no-delay input.  Try this patch (untested):

On a *quick* test ('cause that pesky day job is getting in the way!) I
got the same results with the patch in place.  That is, it runs fine
from the command line but dumps core when run from cron.

If I get bored today I'll recompile with -g and see what the debugger
can tell me.

-- 
----------------------------------------------<Steven King, king@cig.mot.com>--
The trouble with living in sin is the shortage of closet space.
                                                                 (Missy Dizick)
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads