home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!ferkel.ucsb.edu!taco!rock!stanford.edu!agate!ames!olivea!charnel!rat!koko.csustan.edu!altair.csustan.edu!alfredo
- From: alfredo@altair.csustan.edu (ALFREDO MARTINEZ)
- Newsgroups: comp.unix.shell
- Subject: Self extractable shell script archive.
- Summary: This is a shell script that archives files in uuencoded form.
- Message-ID: <1992Nov16.235131.27610@koko.csustan.edu>
- Date: 16 Nov 92 23:51:31 GMT
- Sender: news@koko.csustan.edu (USENET News System)
- Organization: CSU Stanislaus
- Lines: 107
-
- Here is a little shell script that will allow you to contruct
- a self extractable shell script with files in uuencoded form.
- This can be particularly handy for posting or e-mailing binary
- and/or ordinary files.
-
- Although I spend quite a deal of time trying to make this script
- bug-free, I am sure it is not perfect. Up until now I have found
- this script to come in very handy and works like a charm.
- When you save this shell script be sure to remember to "chmod" it to
- make it executable. Otherwise you will have to be "sh" ing. To make
- it executable you can do one of the following:
- chmod u+x selfx
- -or-
- chmod 700 selfx
- Where selfx is the name of the ifollowing shell script.
-
- Enjoy :)
- ------------------------------CUT HERE-----------------------------
- #! /bin/sh
- # file: selfx
- # This is a shell script that will produce a self extracting archive
- # which is uuencoded. This can be useful for posting binary or executables.
- trap 'echo "Aborting...";/bin/rm ${OUTFILE};exit 1' 1 2 3 15
- OUTPUT=
- COUNTER=0
- if [ $# -le "1" ]
- then
- echo "Usage: ${0} outputname sourcefile sourcefile2 ..."
- echo "Where outputname is the name of the self extracting archive"
- echo "and sourcefile(s) are the files that you wish to archive."
- echo "Wildcards such as * and ? may be used if desired."
- exit 1
- else
- OUTFILE=${1}
- if [ -s "${OUTFILE}" ]
- then
- echo "File: ${OUTFILE} already exists"
- exit 1
- else
- echo "Creating self extractable archive ${OUTFILE} "
- echo ""
- echo "#! /bin/sh" >> ${OUTFILE}
- echo "# **********************************************************" >> \
- ${OUTFILE}
- echo "# This is a self extracting archive shell script." >> ${OUTFILE}
- echo "# You can extract by typing: sh filename, where filename" \
- >> ${OUTFILE}
- echo "# is the name of this file." >> ${OUTFILE}
- echo "# Created `date` by user `who am i|awk '{print $1}'`" >> ${OUTFILE}
- echo "# This archive contains the following files:" >> ${OUTFILE}
- echo "Assessing file(s). One moment please ..."
- for myfile in `ls $*`
- do
- if [ -f "${myfile}" -a "${myfile}" != "${OUTFILE}" ]
- then
- COUNTER=`expr ${COUNTER} + 1`
- ls -l ${myfile}|awk '{print "# File -----> " $8" : " $4 " bytes"}' \
- >> ${OUTFILE}
- fi
- done
- echo "# Total number of file(s) = ${COUNTER} " >> ${OUTFILE}
- echo "# **********************************************************" >> \
- ${OUTFILE}
- echo "Archiving ${COUNTER} file(s)."
- echo ""
- chmod 700 ${OUTFILE}
- echo "" >> ${OUTFILE}
- echo "" >> ${OUTFILE}
- echo "trap 'echo "Aborting...";exit 1' 1 2 3 15" >> ${OUTFILE}
- echo "echo 'Unarchiving all files in ${OUTFILE} '" \
- >> ${OUTFILE}
- echo "" >> ${OUTFILE}
- shift
- for arg do
- if [ ! -s "${1}" ]
- then
- echo " ${1} does not exist or is empty."
- else
- if [ ! -d "${1}" ]
- then
- OUTPUT="YES"
- echo "Adding ${1} to ${OUTFILE}."
- echo "echo 'Extracting ${1} ...'" >> ${OUTFILE}
- echo 'uudecode << "XXXXEORXXXX"' >> ${OUTFILE}
- uuencode ${1} ${1} >> ${OUTFILE}
- echo "XXXXEORXXXX" >> ${OUTFILE}
- fi
- fi
- shift
- done
- echo ""
- if [ -z "${OUTPUT}" ]
- then
- echo "No file(s) found."
- echo "Archive ${OUTFILE} was not created."
- /bin/rm ${OUTFILE}
- else
- echo "Archive ${OUTFILE} is now a self extractable archive."
- fi
- fi
- fi
- ------------------------------CUT HERE-----------------------------
- --
- --------------------------------------------------------------------------------
- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- | Alfredo Martinez
- _______________________________________| e-mail (alfredo@altair.csustan.edu)
- Cogito cogito, ergo cogito sum. ( I think I think, therefore I think I am.)
-