Path: utzoo!utgpu!watmath!clyde!att!oucsace!norden
From: norden@oucsace.cs.OHIOU.EDU (Jeffrey Norden)
Newsgroups: comp.binaries.ibm.pc.d
Subject: A unix unpacking script
Message-ID: <371@oucsace.cs.OHIOU.EDU>
Date: 2 Dec 88 02:39:04 GMT
Reply-To: norden@oucsace.UUCP (Jeffrey Norden)
Organization: Ohio University CS Dept., Athens
Lines: 73

Below is a shell script which unix users may find helpful for unpacking the
offerings from comp.binaries.ibm.pc The script depends upon the uuencoded
info being bracketed between "BEGIN--cut here" and "END--cut here" lines.
The comments at the begining explain its use.
The grep at the end for finding the size and checksum in the comments of the
first file is kind of a kludge, but it seems to work.
Enjoy.
	-Jeff Norden, norden@ace.cs.ohiou.edu
	 Dept of Math, Ohio University, Athens, OH  45701

Cut here-------- snip ----------- snip --------- snip --------- Cut here
#! /bin/sh
# ibm-unpack: a shell script to create arc files from the messages
# distributed on the comp.binaries.ibm.pc newsgroup.
# -Jeff Norden, norden@ace.cs.ohiou.edu  Dec 1988
#   If foo1 foo2 and foo3 are files which contain the uuencoded version of
# foo.arc which you got off the net (including mail headers, etc), then
# invoking  "ibm-unpack foo?" will extract foo.arc for you.
#   Features/bugs: (1) zcat will be invoked on any file whose name ends
# in .Z, so you can keep your files compressed in order to save disk space.
# (2) if uudecode works ok, the size and checksum of the resulting file is
# printed, along with the info from the first distribution file, so you can
# compare them, (3) if there is more than one file, they must be specified
# in the correct order, (4) the size and checkusm stuff depends upon the
# format of the distribution files remaining the same as they are now.

usage="Usage: ibm-unpack file1 file2 ..."
if [ $# -eq 0 ]
then
  echo $usage; exit;
fi

SUM="sum -r"
TEMP=tmp$$.uue

rm -f $TEMP

echo Creating temp file...
for filename in $*
do
  if [ -z  "`echo $filename | grep \\.Z\$`" ]
  then
	CAT=cat
	echo " extracting data from $filename"
  else
	CAT=zcat
	echo " extracting data from $filename (using zcat to uncompress)"
  fi

${CAT} $filename | awk "
/^END--cut here/ {exit}
{if (printing) print}
/^BEGIN--cut here/ {printing=1}" >> $TEMP

done

echo; echo uudecoding...
uudecode < $TEMP || exit
rm -f $TEMP

echo;
echo info from the distribution:
echo "checksum     size (bytes)  file"
if [ -z  "`echo $1 | grep \\.Z\$`" ]
then
 grep "^ .*arc\$" $1
else
 zcat $1 | grep "^ .*arc\$"
fi
echo here is what we got:
 ls -l *.arc; echo "checksum: " `sum -r *.arc`

Cut here-------- snip ----------- snip --------- snip --------- Cut here