Article View: news.software.readers
Article #5302Re: Saving multipart postings in order using rn (readnews)
From: Jeremy Mathers
Date: Mon, 16 Aug 1993 15:55
Date: Mon, 16 Aug 1993 15:55
87 lines
3968 bytes
3968 bytes
In article <CBHn81.IrL@cs.dal.ca> lane@cs.dal.ca (John Wright/Dr. Pat Lane) writes:
>Something I've been wondering for a while...sorry if it's an FAQ.
>(I expect that it is).
>
>Readnews (rn) lists articles by article number using the "=" command.
>You can list a subset of articles based on a string pattern in the
>Subject heading with /pattern/=. You can save the articles to a file
>with /pattern/s file. You can modify the scope of the search to include
>say, the entire header, using /pattern/h:=.
This issue is discussed over and over in the various binaries groups
(particularly, in the alt groups) and the "official" solution is to get
one of the many "smart uudecoders" - that is programs that can be fed
the pieces in any order and they sort it out and do the right thing.
However, I find this approach too high tech (*), and so I wrote the
following little script that simply sorts a mailbox formatted file into
a user specified order.
To use it, you enter the piece numbers in the order in which they appear
in the mail file, one per line, followed by a ^D. The program also
handles the case where you have multiple things to be uudecoded, and the
pieces of the various files are intermixed with each other. Anyway, it
is kind of a low-tech solution, but it has worked OK for me.
(The script uses two non-standard utilities - pause (which I wrote) and
uuconvert (which is available on the net))
------ Cut here -------
: Sort mail for uuencoding.
case $# in
1) if [ ! -f $1 ]
then echo "Mailbox file: $1 - not found"
exit 1
fi
;;
*) echo "Arg count error"
exit 1
;;
esac
tmp=/tmp/tmp$$
trap "rm $tmp" 0 1 2 3 15
set -e
echo "Enter the order as stored in the mail file..."
nawk '
NF > 0 { gsub(/[^0-9]+/," ") ; x[sprintf("%05d%05d",$1,$2)] = ++nr }
END {
n = ArraySort(x,x1)
for (i=1; i<=n; i++)
print "s",x[x1[i]],tmp
print "x"
}
#
function ArraySort(In,Out, i,j) {
for (i in In)
Out[++j] = i
qsort(Out,1,j)
return (Out[0] = j)
}
# qsort - sort A[left..right] by quicksort
function qsort(A,left,right, i,last) {
if (left >= right) # do nothing if array contains
return # less than two elements
swap(A, left, left + int((right-left+1)*rand()))
last = left # A[left] is now partition element
for (i = left+1; i <= right; i++)
if (A[i] < A[left])
swap(A, ++last, i)
swap(A, left, last)
qsort(A, left, last-1)
qsort(A, last+1, right)
}
function swap(A,i,j, t) { t = A[i]; A[i] = A[j]; A[j] = t }
#
function Delete(arr) { split("",arr) }
' tmp=$tmp | mail -N -f $1
pause "Press <Esc> to exit; any other to uuconvert & test-pix it..." || exit
uuconvert $tmp
test-pix `nawk '/^begin/ { print $NF }' $tmp`
rm -i $1
************************************************************************
The Zapruder film was a snuff film.
- pynq@quads.uchicago.edu, who is still costing the net
hundreds, if not thousands, of dollars, every time he posts -
************************************************************************
rwvpf wpnrrj ibf ijrfer
Technical Details
Message-ID:
<1993Aug16.155547.15077@midway.uchicago.edu>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!archive!mbox2nntp-news.software.readers.mbox.zip!gmd.de!xlink.net!howland.reston.ans.net!vixen.cso.uiuc.edu!uwm.edu!linac!uchinews!quads!pynqReferences:
<CBHn81.IrL@cs.dal.ca>Show Full Headers
Complete Article Headers
Message-ID: <1993Aug16.155547.15077@midway.uchicago.edu> Subject: Re: Saving multipart postings in order using rn (readnews) Date: Mon, 16 Aug 1993 15:55:47 GMT From: pynq@quads.uchicago.edu (Jeremy Mathers) References: <CBHn81.IrL@cs.dal.ca> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!archive!mbox2nntp-news.software.readers.mbox.zip!gmd.de!xlink.net!howland.reston.ans.net!vixen.cso.uiuc.edu!uwm.edu!linac!uchinews!quads!pynq Newsgroups: news.newusers.questions,news.software.readers Sender: news@uchinews.uchicago.edu (News System) Reply-To: pynq@midway.uchicago.edu Organization: D. J. Dougherty & Associates Distribution: na Lines: 87