Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!ucla-cs!zen!ucbvax!sdcsvax!ucsdhub!esosun!seismo!uunet!munnari!moncskermit!goanna!yabbie!cit5!steve From: steve@cit5.UUCP Newsgroups: comp.sources.d Subject: Re: How do you create a shell archive? Message-ID: <181@cit5.oz> Date: Fri, 18-Sep-87 13:28:03 EDT Article-I.D.: cit5.181 Posted: Fri Sep 18 13:28:03 1987 Date-Received: Sun, 20-Sep-87 20:54:49 EDT References: <1152@bsu-cs.UUCP> <545@clsib21.UUCP> Organization: Chisholm Institute of Technology, Melb, Australia Lines: 86 In article <545@clsib21.UUCP>, dave@clsib21.UUCP (David P. Hansen) writes: > Being rather new to Unix, I haven't yet discovered what utilities are > used to pack a shell archive. What's available or does everyone have > there own program. Would anyone out there like to share what they have?? I hope people don't mind this appearing in this newsgroup, but my spur-of-the- moment scripts for creating shar files follows below. I make no pretence that it is the best way to do it, but it does work. Each time you run it, you should rename the output file which is called "shar_out" to something else. One day, I may even fix this deficiency up. (if I get the time :-) If you need to do any other shell-type commands, then these can be added in with an editor after all the files are archived. The main file follows..... ------cut-------cut--------cut---------cut---------cut---------cut-------cut--- # Creates a shar file for posting sources to ACSnet. # Output is always to "shar_out" # # Usage: mkshar file_template # # Calls subroutine "mksh" for each member file. # if test -f 'shar_out' then echo "mkshar: \"'shar_out'\" already exists; will not over-write." else echo "#---cut here---cut here---cut here---cut here---cut here---" >shar_out echo "#! /bin/sh" >>shar_out echo "# This is a shell archive, meaning:" >>shar_out echo "# 1. Remove everything above the #! /bin/sh line." >>shar_out echo "# 2. Save the resulting text in a file." >>shar_out echo "# 3. Execute the file with /bin/sh (not csh) to create the files." >>shar_out echo "# This archive created: `date`" >>shar_out echo "# Archived by: `cat $HOME/.netname`" >>shar_out echo "export PATH; PATH=/bin:\$PATH" >>shar_out ff=`ls $*` for f in $ff do echo mkshar: packing \'$f\' mksh $f `wc -c <$f` done echo "# End of shell archive" >>shar_out echo "exit 0" >>shar_out echo echo "***** Resulting shar file is in 'shar_out'" fi cat $HOME/.signature >>shar_out ------cut-------cut--------cut---------cut---------cut---------cut-------cut--- The following script is called "mksh" and is called by "mkshar" for each file to be archived. ------cut-------cut--------cut---------cut---------cut---------cut-------cut--- # Called by "mkshar" to create the file part of a shar file. # # Usage: mksh filename filesize # # Must be called by "mkshar" otherwise the header and trailer of the shar file # will be missing. # echo "echo shar: extracting \"'$1'\" '($2 characters)'" >>shar_out echo "if test -f '$1'" >>shar_out echo "then" >>shar_out echo " echo shar: will not over-write existing file \"'$1'\"" >>shar_out echo "else" >>shar_out echo "sed 's/^X//' << \\SHAR_EOF > '$1'" >>shar_out sed 's/^/X/' <$1 >>shar_out echo "SHAR_EOF" >>shar_out echo "if test $2 -ne \"\`wc -c < '$1'\`\"" >>shar_out echo "then" >>shar_out echo " echo shar: error transmitting \"'$1'\" '(should have been $2 characters)'" >>shar_out echo "fi" >>shar_out echo "fi # end of overwriting check" >>shar_out ------cut-------cut--------cut---------cut---------cut---------cut-------cut--- I hope this helps you out, Steve. - - - - - (It's my opinion and not my employers) Steve Balogh VK3YMY | steve@cit5.cit.oz (...oz.au) Chisholm Institute of Technology | steve%cit5.cit.oz@uunet.uu.net PO Box 197, Caulfield East | Melbourne, AUSTRALIA. 3145 | {hplabs,mcvax,uunet,ukc}!munnari\ +61 3 573 2266 (Ans Machine) | !cit5.cit.oz!steve