Path: utzoo!utgpu!water!watmath!clyde!rutgers!husc6!cmcl2!brl-adm!umd5!decuac!felix!preston From: preston@felix.UUCP (Preston Bannister) Newsgroups: comp.sources.d Subject: Re: Suggestion for shar file posting Message-ID: <19698@felix.UUCP> Date: 26 Jan 88 19:44:43 GMT References: <661@silver.bacs.indiana.edu> Sender: daemon@felix.UUCP Reply-To: preston@felix.UUCP (Preston Bannister) Distribution: na Organization: FileNet Corp., Costa Mesa, CA Lines: 115 In article <661@silver.bacs.indiana.edu> creps@silver.UUCP (Steve Creps) writes: > After having unshar'ed many programs, one thing I've noticed that >causes extra work is having to edit the file before unshar'ing it. >It would be nice if I could "w" it from rn, then unshar it without >having to do any editing. >.... Someone posted a useful little shell script for automatically unpacking articles containing shar scripts a year or so ago. I find it extremely useful. Usually from 'rn' I can type '|rnget newdir' and the script will create 'newdir' if necessary and unshar the article into 'newdir'. The script is short... ------------- cut here ------------- #!/bin/sh # # NAME # rnget - get a shar archive from rn output. # # SYNOPSIS # rnget [-p pattern] [-r file] [f prog] [ directory ] # # DESCRIPTION # Rnget changes to the given directory (if given) and then # reads its standard input and searches for the given pattern # (default to "[#:]") at the beginning of a line and passes that # and all subsequent lines to the filter, defaulting to the # bourne shell, for processing. Lines prior to the first line # matching the pattern are saved to the file, default READ_ME. # # The idea is that the input is a shar file contained inside # of a news article, with a scan done before hand for the # beginning of the shar. For shars that don't begin with '#' # or ':' -p can be used to specify something else. # # Note: If the directory does not exist, it is created. prog="$0" usage="usage: $prog [-p pattern] [-r file ] [-f prog] [directory]" pattern="/^[:#]/" readme="READ_ME" filter=/bin/sh while [ $# -gt 0 ]; do if [ flag$1 = flag-p ]; then shift if [ $# -lt 1 ]; then echo $usage exit 1 fi pattern="/^$1/" echo "$prog: Trigger pattern is $pattern." shift elif [ flag$1 = flag-f ]; then shift if [ $# -lt 1 ]; then echo $usage exit 1 fi filter=$1 echo "$prog: Filter is $filter." shift elif [ flag$1 = flag-r ]; then shift if [ $# -lt 1 ]; then echo $usage exit 1 fi readme="$1" echo "$prog: Header information is in $readme." shift else # got a directory if [ -f $1 ]; then echo "$prog: $1 is not a directory!!" exit 2 fi if [ ! -d $1 ]; then mkdir $1 > /dev/null 2>&1 if [ $? -ne 0 ]; then echo "$prog: Could not create directory $1." exit 2 fi fi cd $1 echo "$prog: Directory is $1." shift fi done # rm -f $readme awk " BEGIN { skip = 1; copy = 2; state = skip; } state == skip && $pattern { state = copy; } state == skip { print \$0 >> \"$readme\"; } state == copy { print \$0 }" | $filter if [ $? -ne 0 ]; then echo "$prog: error in writing to shell" fi -- Preston L. Bannister USENET : ucbvax!trwrb!felix!preston BIX : plb CompuServe : 71350,3505 GEnie : p.bannister