Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!cs.utexas.edu!uunet!zephyr.ens.tek.com!tekcrl!tekgvs!keithe From: keithe@tekgvs.LABS.TEK.COM (Keith Ericson) Newsgroups: comp.binaries.ibm.pc.d Subject: Re: Getting files from c.b.i.p (explanation) Message-ID: <5682@tekgvs.LABS.TEK.COM> Date: 31 Jul 89 21:16:12 GMT References: <7479@cg-atla.UUCP> Reply-To: keithe@tekgvs.LABS.TEK.COM (Keith Ericson) Organization: Tektronix, Inc., Beaverton, OR. Lines: 146 In article <7479@cg-atla.UUCP> granger@cg-atla.UUCP (Pete Granger) writes: >Maybe I shouldn't be doing this, because my ways for doing things may not work >for everyone. My scheme may not work for everyone, either, but here's how I"ve semi-automated my work of saving CBIP postings. I use rn running on a BSD 4.2 machine to read news. The salient point here is that it allows the current article to be piped out to a subordinate process " | ." So I've developed a KORN shell script (included below) I call nwr ("News WRite") to simplify saving multiple-part CBIP postings. It is used in two modes: first-article-mode and subsequent-article(s)-mode. When the first of a series of articles appears I want to save I tye in | nwr such as | nwr ibm.dir/editors/vi.dir/part1 If the directory specified does not exist you will be prompted to either have it created, or enter a new name, or to exit. This helps insure you get the file where you want it and not where your fingers may have mistakenly told it to go :-) Subsequent articles can then be saved by providing only the file-name portion of the path, such as | nwr part2 and nwr will provide the basename (as it's called) for you. The most recently entered basename is stored away in a file in your $HOME directory. (By the way - does anyone know how to store this information in an environmental variable instead of saving it away in a file?) I find this tool saves me a lot of work - I stash away almost everything Rahul distributes - and particularly alleviates the typo errors in trying to save the articles away. Once I have all the parts saved away I either cat them all through a filter (implemented with a KSH alias) I call "udec" (also included below) or I access them via PC-NFS and use Richard Marx's (excellent) uudecode program on them. Hope these scripts are of some use. Remember, "nwr" is a KORN shell script - I think it won't work with a Bourne shell (sorry). And "udec" is a (KSH?) alias. kEITHe =========================================================================== BEGIN nwr: #!/usr/tools/bin/ksh # replace with the path to your ksh if the above isn't correct NEWDIR=0 NEWFILE=0 # script to use within rn to save keystrokes while saving # multiple-part articles. This remembers the directory # name in $HOME/.nwrsavedir for automatic retrieval. case $# in 1) DESTDIR=${1%"`basename $1`"} if [ "$DESTDIR" = "" ] then DESTFILE=${1} read DESTDIR < $HOME/.nwrsavedir else DESTFILE=`basename ${1}` print "${DESTDIR}" > $HOME/.nwrsavedir fi ;; *) echo "usage: nwr [destdir-path/]destfile" exit ;; esac print DESTDIR = ${DESTDIR%"/"} print DESTFILE = $DESTFILE while [ $NEWDIR = 0 ] do if test -d ${DESTDIR%"/"} then NEWDIR=1 else read ans?"${DESTDIR} does not exist: create, new name or exit (c/n/e)?" < /dev/tty case $ans in c|C) mkdir ${DESTDIR%"/"} if $? then print "${DESTDIR%"/"} created" else print "Cannot create ${DESTDIR%"/"}" fi ;; n|N) read DESTDIR?"input new directory name: " < /dev/tty print "${DESTDIR}" > $HOME/.nwrsavedir ;; e|E) exit;; *) print "Huh?" ;; esac fi done while [ $NEWFILE = 0 ] do if [ -f "${DESTDIR}${DESTFILE}" ] then read ans?"${DESTFILE} exists: replace, append or new name (r/a/n)?" < /dev/tty case $ans in r|R) print "replacing ${DESTDIR}${DESTFILE} with this article" cat <&0 > ${DESTDIR}${DESTFILE} NEWFILE=1 ;; a|a) print "appending this article to ${DESTDIR}${DESTFILE}" cat <&0 >> ${DESTDIR}${DESTFILE} NEWFILE=1 ;; n|N) read DESTFILE?"input new file name" < /dev/tty ;; esac else print "saving current article to ${DESTDIR}${DESTFILE}" cat <&0 > ${DESTDIR}${DESTFILE} NEWFILE=1 fi done set +x END nwr =========================================================================== BEGIN udec alias udec="sed '/^END-/,/^BEGIN-/d'| uudecode" END udec ===========================================================================