[comp.unix.questions] Shar program needed

netnews@psc90.UUCP (Remote mail paths) (05/07/89)

Hi,

	I am looking for a program which will "shar" (pack) a large program for
posting to the net. At the moment I am only able to unshar using "sh."

Thanks

Deryk




  ......................................................................
  \      ...Deryk C. Marien                                            /
   \     .  Plymouth State College, Computer Services                 /
    >----.  Plymouth, NH  03264 -------------------------------------<
   /     .  UUCP: !uunet!unh!psc90!netnews or !dartvax!psc90!netnews  \
  /      ...BITNET: D_MARIEN@UNHH                                      \
 /..........COMPUSERVE (72701,2200).....................................\

gwyn@smoke.BRL.MIL (Doug Gwyn) (05/08/89)

In article <894@psc90.UUCP> netnews@psc90.UUCP (Remote mail paths) writes:
>I am looking for a program which will "shar" (pack) a large program for
>posting to the net. At the moment I am only able to unshar using "sh."

Although there are zillions of "shar" implementations, I just use
"bundle" from Kernighan & Pike's "The UNIX Programming Environment".
Be warned that the moderator(s) of USEnet source newsgroups seems to
think that it is important to accommodate brain-damaged mailers, but
my preference is to give them all the grief I can in the hope that
eventually the complaints from their clientele will cause them to be
fixed.

jik@athena.mit.edu (Jonathan I. Kamens) (05/08/89)

In article <894@psc90.UUCP> netnews@psc90.UUCP (Remote mail paths) writes:
>Hi,
>
>	I am looking for a program which will "shar" (pack) a large program for
>posting to the net. At the moment I am only able to unshar using "sh."

The cshar package, written by Rich Salz and available in volume 15 of
the comp.sources.unix archives (either anonymous ftp to uunet.uu.net,
or UUCP mail archives {about which I know absolutely nothing and
therefore can't tell you how to use :-)}), is the most complete
package I've seen.

It produces robust archives that will survive nearly all mailers, and
includes the "makekit" program which will automatically take a large
set of source files and put them into multiple shar files that are
small enough to be mailed.

It also adds the lines to the bottom of shar files that say things
like, "You've got the archive," or "You still need to unpack archives
2 3 4 ..." which are a help.

Jonathan Kamens			              USnail:
MIT Project Athena				410 Memorial Drive, No. 223F
jik@Athena.MIT.EDU				Cambridge, MA 02139-4318
Office: 617-253-4261			      Home: 617-225-8218

drears@pica.army.mil (Dennis G. Rears (FSAC)) (05/08/89)

Deryk C. Marien writes:
 
>Hi,
>
>	I am looking for a program which will "shar" (pack) a large program for
>posting to the net. At the moment I am only able to unshar using "sh."
>
   This is a short script so I am posting it to the net.  This was
given to me by a friend.  

Dennis



----------------------------------------------------------------------
#!/bin/sh
# @(#)shar.sh	1.6 8/15/86 - make a shell archive of specified files
#
# This is useful for preparing files for transfer to another site.
#
# Usage:  shar file [file ...] >outfile
#
# Files may also contain directory pathnames.
#
#  Informative messages will be written to stderr.
#
# Jack Moskowitz    <jackm@qa1.pica.army.mil>
#
# check for at least one file specified
if [ $# -lt 1 ]
then
	echo "Usage: shar file [file ...] >outfile" 1>&2
	exit
fi
# set up the beginning commands in the output file
echo "#!/bin/sh"
echo "#"
echo "# This is a shell archive.  To extract its contents,"
echo "# execute this file with /bin/sh to create the files:"
echo "`ls $* | pr -4 -t -w80 | sed \"s/^/# /\"`"
echo "#"
echo "# This shell archive created: `date`"
echo "#"
#
for arg in $*
do
	arg=`echo $arg | sed "s/^\.\///"`
	path=$arg
	if [ ! -f $path ]
	then
		if [ ! -d $path ]
		then
			echo "File $path does not exist. Skipping..." 1>&2
		fi
		continue
	fi
	len=`wc -c <$path`
	echo "Archiving file $path, length $len" 1>&2
	dir=.
	for file in `echo $path | tr '/' ' '`
	do
		if [ $file = . ]
		then
			continue
		fi
		dir=$dir/$file
		if [ -d $dir ]
		then
			echo "if [ ! -d $dir ]"
			echo "then"
			echo "echo \"Making directory $dir\""
			echo "mkdir $dir"
			echo "fi"
		else
			echo "echo \"extracting file $path\""
			echo "sed -e 's/^X//' <<\*EOF > $path"
			sed -e "s/^/X/" $path
			echo "*EOF"
			echo "if [ \`wc -c <$path\` -ne $len ]"
			echo "then"
			echo "	echo \"lengths do not match -- Bad Copy of $path\""
			echo "fi"
		fi
	done
done
echo "echo \"Done.\""
echo "Done." 1>&2
----------------------------------------------------------------------