[comp.unix.questions] rn as a batch process, again

packer@chrpserv.gsfc.nasa.gov (Charles Packer) (12/16/89)

This message supercedes an earlier one.

I would like to run "rn" as a batch process to get all the
messages from selected newsgroups into a file or files
so that I can FTP them over to the VAX, a programming 
environment in which I am more at home.  I tried a command
procedure (or "script", as they're known here) that simply
invoked rn and then exited with a "q", like this:

	rn
	q

but it bombed with a message "Caught a SIGSEGV--.newsrc restored".
Then I learned how to redirect input using "<". So I created
a file of rn commands, "aa.com", to use in the command "rn<aa.com".
I tried something simple:

	n
	n
	n
	q

I figured that if I typed in the line "rn<aa.com" it would invoke
rn, pass by three news groups, and exit.  Instead, it seemed to
hang on the first "n", since it got into an infinite loop of
passing by newsgroups until I issued a Ctrl-Z.

bph@buengc.BU.EDU (Blair P. Houghton) (12/17/89)

In article <611@dftsrv.gsfc.nasa.gov> packer@chrpserv.gsfc.nasa.gov (Charles Packer) writes:
>I would like to run "rn" as a batch process to get all the
>messages from selected newsgroups into a file or files
>so that I can FTP them over to the VAX, a programming 
>environment in which I am more at home.

You're much better off using a sh(1) script that uses find(1)
to collect the articles for you.

#! /bin/sh
while read group
do
    groupdir=/usr/spool/news/`echo $group | tr . /`
    find $groupdir -mtime 1 -exec cat {} \; > /usr/tmp/outfile.$group
done < $HOME/.copygroups

where .copygroups is a file in your home directory containing
the names of the groups you are interested in one per line like so:

comp.unix.questions
rec.arts.startrek
alt.flame
comp.os.vms

et cetera; this is much less information than is in a .newsrc file.

All of the articles written into the group's directory within the past
day will be concatenated and placed in a file in the current directory
with a name like "outfile.comp.unix.questions".  You can change the form
of this name without hurting anything, of course.

Note to the experts:  I know it can be made a one-liner, but who cares?

				--Blair
				  "And who'd type it into the
				   command line?"