Thread View: news.software.readers
4 messages
4 total messages
Started by Jonathan I. Kamens
Tue, 07 Apr 1992 14:45
Re: How to save specific header line with 'rn' ?
Author: Jonathan I. Kamens
Date: Tue, 07 Apr 1992 14:45
Date: Tue, 07 Apr 1992 14:45
44 lines
3106 bytes
3106 bytes
In article <1992Apr6.213356.7296@ccu.umanitoba.ca> jlim@silver.cs.umanitoba.ca (Tung Tseung Johnny Lim) writes:
(Sorry if this is not the right group to post this message)
None of the groups you chose were the "right" one.
News.software.readers is for discussing news readers. I have
cross-postd and directed followups there.
I am new to the 'rn' program and find it very interesting. I have checked
the manual for 'rn' (man rn) and could not solve my problem.
I would like to be able to save some news without including all the
header lines (i.e. just to include: Date, From and Subject).
Rn uses the %X/norm.saver and %X/mbox.saver shell scripts to save
articles, where %X is the compiled-in location of rn's private library
directory (possibly /usr/lib/rn or /usr/local/lib/rn or something like
that; you'll have to ask someone locally, or type "!echo %X" in rn, to
find out where it is at your site). You can tell rn to use different
shell scripts, and either (a) have those shell scripts strip off the
headers you don't want before feeding the article to the actual
mbox.saver or norm.saver scripts, or (b) actually make those shell
scripts modified copies of the mbox.saver and norm.saver scripts, so
that they save directly.
See the rn man page to find out how to use different mbox.saver and
norm.saver scripts.
I know that I can just type in: s in 'rn' to save an article or a range of
articles, but I don't know how I can "customize" 'rn' to omit other header
lines when saving.
Rn saves articles with the same header lines it displays on-screen.
You could actually use the '&' command to hide the headers you don't
want and then save the article, but that's quite cumbersome,
especially since you'll have to undo your settings if you keep on
reding news.
--
Jonathan Kamens jik@MIT.Edu
MIT Information Systems/Athena Moderator, news.answers
(Send correspondence related to the news.answers newsgroup
{and ONLY correspondence related to the newsgroup}
to news-answers-request@MIT.Edu.)
Re: How to save specific header line with 'rn' ?
Author: Paul Close
Date: Tue, 07 Apr 1992 18:22
Date: Tue, 07 Apr 1992 18:22
80 lines
4469 bytes
4469 bytes
jik@athena.mit.edu (Jonathan I. Kamens) writes:
>jlim@silver.cs.umanitoba.ca (Tung Tseung Johnny Lim) writes:
>
> I am new to the 'rn' program and find it very interesting. I have checked
> the manual for 'rn' (man rn) and could not solve my problem.
> I would like to be able to save some news without including all the
> header lines (i.e. just to include: Date, From and Subject).
>
>Rn uses the %X/norm.saver and %X/mbox.saver shell scripts to save
>[...]
>
>See the rn man page to find out how to use different mbox.saver and
>norm.saver scripts.
Specifically, see the entries for MBOXSAVER and NORMSAVER. These default to
calling %X/mbox.saver and %X/norm.saver with arguments. I've included an
example below that deals with %X, so don't worry.
>Rn saves articles with the same header lines it displays on-screen.
This is is not true. Rn just saves the article as it appears in the spool
file. Look at either saver program (they're just shell scripts).
The best way to do this is to write a shell script to strip the headers you
don't want. I whipped up an expample (even tested it! :-)
In RNINIT (or the file RNINIT points to):
-EMBOXSAVER='$HOME/bin/mysaver %X/mbox.saver %A %P %c %a %B %C "%b" "From %T %`date`"'
-ENORMSAVER='$HOME/bin/mysaver %X/norm.saver %A %P %c %a %B %C "%b"'
In $HOME/bin/mysaver:
-----------------------cut here-------------------------
#!/bin/sh
saver=$1
file=$2
shift; shift
cat $file |
sed -e '/^Path: /d' -e '/^Message-ID: /d' -e '/^Path: /d' |
$saver "" "$@"
-----------------------cut here-------------------------
Now let me explain what these do. First of all, note that there is a bug in
the mbox.saver man page. The From: should be just From. The rn code gets
it right, it's the man page that's wrong.
The two -Exxx lines tell rn to substitute the following lines for the MBOX
saver and NORM saver. Since "mysaver" is just a filter, you can use it for
both programs. Next, the name of the real saver program is next. That way
rn expands the %X for you, and you don't have to worry. After that is just
the arguments the rn saver programs expect (from the man page).
The shell script does the following. First it parses out the name of the
saver program and the saver program's first arg, which is the file to get
input from. The two shifts move the argument list to make it convenient
to pass the rest of the args to the saver program. Then we pipe the news
article into sed, which removes the lines you don't want, and pipe the
output of sed into the rn saver program.
Two notes here: the "" after saver pass a null first argument to the saver
prog. If you look at the source for the two shell scripts, you'll see they
both use "tail" on their first arg, expecting a filename. By making this
null, both programs will read from stdin, which we want. Second note: "$@"
expands the args like this: "arg1" "arg2" and so on (which we also want, to
preserve the "From xxx" last arg's spaces).
There you have it! One note: the sed line will remove *any* lines that
begin with Path:, etc. There's no way for sed to know if the Path: line
is part of the header or message body. In practice this shouldn't be a
problem. The '^' in the sed lines tells sed to only match that pattern
if it is at the beginning of the line. You can add quite a number of -e
patterns to sed before it'll complain. All seds are different in this
respect, so see what works on your system.
Enjoy!
--
Paul Close pdc@sgi.com ...!{ames, decwrl, uunet}!sgi!pdc
Oh, no! You walked into the slavering fangs of a lurking grue.
Re: How to save specific header line with 'rn' ?
Author: Sridhar Venkataraman
Date: Tue, 07 Apr 1992 18:23
Date: Tue, 07 Apr 1992 18:23
55 lines
2943 bytes
2943 bytes
jik@athena.mit.edu (Jonathan I. Kamens) writes on news.software.readers:
) I am new to the 'rn' program and find it very interesting. I have checked
) the manual for 'rn' (man rn) and could not solve my problem.
) I would like to be able to save some news without including all the
) header lines (i.e. just to include: Date, From and Subject).
)
)See the rn man page to find out how to use different mbox.saver and
)norm.saver scripts.
)
) I know that I can just type in: s in 'rn' to save an article or a range of
) articles, but I don't know how I can "customize" 'rn' to omit other header
) lines when saving.
)
)Rn saves articles with the same header lines it displays on-screen.
)You could actually use the '&' command to hide the headers you don't
)want and then save the article, but that's quite cumbersome,
)especially since you'll have to undo your settings if you keep on
)reding news.
I am not sure rn does this. I have restricted my header lines to just
3 of them but saving them always saves the entire headers.
Since rn does a byte-count determination for the 'w'
command (which is not so obvious to many readers who have read TFM),
it is especially useful in discarding unwanted headers.
Since I prefer mbox format in saving, I hereby give a patch for
mbox.saver which will let the user save articles with preferred
headers. (Use 'w' instead of 's')
*** mbox.saver Tue Apr 7 09:51:22 1992
--- oldmbox.saver Sat Feb 1 15:01:44 1992
***************
*** 33,35 ****
( echo "$8"
! sed -n '1,/^$/p' $1 | egrep "^From:|^Subject:|^Newsgroups:"
tail +$5c $1 | sed "s/^From />From /"
--- 33,37 ----
( echo "$8"
! if /bin/test "$5" = 0 -a ! "$4" = 0 ; then
! echo "Article: $4 of $6"
! fi
tail +$5c $1 | sed "s/^From />From /"
The user's customizability may vary. Any other suggestions for this welcome.
Let me caution that use of 's' command with this script is not
recommended.
)Jonathan Kamens jik@MIT.Edu
Sridhar.
Re: How to save specific header line with 'rn' ?
Author: Andrew Hilborne
Date: Thu, 09 Apr 1992 11:37
Date: Thu, 09 Apr 1992 11:37
55 lines
2445 bytes
2445 bytes
In <j8lrq04@fido.asd.sgi.com> pdc@lunch.wpd.sgi.com (Paul Close) discusses
how to save articles in rn without including all the header lines. He suggests
using the following:
>In RNINIT (or the file RNINIT points to):
> -EMBOXSAVER='$HOME/bin/mysaver %X/mbox.saver %A %P %c %a %B %C "%b" "From %T %`date`"'
> -ENORMSAVER='$HOME/bin/mysaver %X/norm.saver %A %P %c %a %B %C "%b"'
>
>In $HOME/bin/mysaver:
>-----------------------cut here-------------------------
>#!/bin/sh
>
>saver=$1
>file=$2
>shift; shift
>
>cat $file |
> sed -e '/^Path: /d' -e '/^Message-ID: /d' -e '/^Path: /d' |
> $saver "" "$@"
>-----------------------cut here-------------------------
I am certainly pleased because I have the impression that NORMSAVER
is now working when rn is compiled to use NNTP. At one time
NORMSAVER stopped working when NNTP support was compiled in.
Paul Close goes on to say:
>There you have it! One note: the sed line will remove *any* lines that
>begin with Path:, etc. There's no way for sed to know if the Path: line
>is part of the header or message body.
This isn't true. The following sed script will delete all except the From:
Subject: and Date: lines. It won't delete anything after the first
blank line:
sed -n -e ': top
/^From: / {
p; n; b top
}
/^Date: / {
p; n; b top
}
/^Subject: / {
p; n; b top
}
/^$/ {
p; n; b bot
}
n; b top
: bot
p; n; b bot
'
--
Andrew Hilborne
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