#! /bin/bash # # mail-shell -- mail out the shell # # usage: mail-shell -t tarball recipient # # Chet Ramey # chet@ins.CWRU.Edu # # Copyright (C) 1995-2002 by Chester Ramey # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. PATH=/usr/ucb:/bin:/usr/bin:/usr/local/bin/gnu:/usr/local/bin:. trap 'rm -f x?? ${UUFILE}' 0 1 2 3 6 15 prog=`basename $0` TARFILE=bash.tar VERS=2.05b while getopts t: opt do case $opt in t) TARFILE=$OPTARG ;; *) echo usage: $prog [ -t tarfile ] recipient 1>&2 exit 1 esac done shift $(( $OPTIND - 1 )) case "$TARFILE" in bash-*.tar) VERS=${TARFILE%%.tar} ; VERS=${VERS#bash-} ;; esac GZFILE=${TARFILE}.gz UUFILE=${GZFILE}.uu if [ $# -ne 1 ] ; then echo usage: $0 recipient exit 1 fi recip=$1 i=1 if [ ! -f ${TARFILE} ] && [ ! -f ${GZFILE} ]; then echo "$prog: no file ${TARFILE}, aborting" exit 1 fi if [ ! -f ${GZFILE} ] ; then echo "$prog: no gzipped tar file ${GZFILE}" echo "$prog: gzipping ${TARFILE}" gzip ${TARFILE} fi if [ ! -f ${UUFILE} ] ; then echo "$prog: no uuencoded tar file ${UUFILE}" echo "$prog: uuencoding ${GZFILE}" uuencode ${GZFILE} < ${GZFILE} > ${UUFILE} fi files=$(echo x??) if [ "$files" = 'x??' ] ; then echo "$prog: no split of ${UUFILE} exists" echo "$prog: splitting ${UUFILE}" split ${UUFILE} fi count() { echo $# } parts=$(count x??) if [ -x /usr/ucb/mail ]; then MAIL=/usr/ucb/mail elif [ -x /usr/ucb/Mail ]; then MAIL=/usr/ucb/Mail elif [ -x /usr/bin/mailx ]; then MAIL=/usr/bin/mailx elif [ -x /usr/bin/mail ]; then MAIL=/usr/bin/mail else MAIL=/bin/mail fi $MAIL -s "bash-${VERS} shipment coming" $recip <