home *** CD-ROM | disk | FTP | other *** search
- #!/bin/sh
- #
- # E-mail files and folders from the command line or a non-NeXT computer.
- #
- # File description and history are at the end of this script (for speed).
- #
- PROG="`basename $0`"
- PATH=/usr/local/bin:/usr/ucb:/usr/bin:/bin
- export PATH
-
- AWK=awk
- CAT=cat
- MAIL="/usr/ucb/Mail"
- TAR="tar chf -"
- UUENCODE=uuencode
-
- TMPDIR=/tmp/${PROG}$$.dir
- TARFILE=${PROG}$$
- ATTACH=${TMPDIR}/${TARFILE}.attach
- INDEX=${TMPDIR}/index.rtf
- TMPFILE=/tmp/${PROG}$$
- USAGE="${PROG} [-] [-s subject] [-f from] [-bulk] [-rt] [-RR] {files|folders|folders/files} [recipients...]"
- PROMPT="echo -n"
- VERBOSE=
- RR="Received: by NeXT Mailer (1.63)"
- SUBJECT="[NeXT-MAIL]"
-
- #
- # Destroy temporary files and folders.
- #
- trap "/bin/rm -rf ${TMPDIR} ${TMPFILE} ; exit" 0 1 2 3 4 5 6 13 15
-
- #
- # Create temporary directory to work in.
- #
- mkdir ${TMPDIR}
-
- #
- # Cycle through command-line arguments.
- #
- while test $# != 0 ; do
- case "$1" in
- - ) # Take a message.
- echo "${PROG}: Enter mail message, terminated with single '.':"
- while test 1 = 1 ; do
- ${PROMPT} "> "
- read INPUT
- if test "${INPUT}" = '.' ; then
- break
- fi
- MAILMESSAGE="${MAILMESSAGE}${INPUT} "
- done
- ;;
- -s ) # set subject:
- OVERRIDE_SUBJECT="$2"
- shift
- ;;
- -f ) # Set From: address.
- FROM=-f${2:-`whoami`}
- shift
- ;;
- -v ) # set verbose mail output.
- VERBOSE=-v
- ;;
- -bulk | -BULK ) # Set Precedence:
- BULK=YES
- ;;
- -r | -rt | -RT ) # set reply-to:
- REPLYTO="$2"
- shift
- ;;
- -R | -RR | -rr ) # set read-receipt
- RR="Received: by NeXT Mailer (1.63.RR)"
- ;;
- -* ) # Unknown argument.
- echo "${PROG}: Unknown argument $1."
- ;;
- /* | ./* | ../* ) # Can't handle full or relative pathnames.
- ln -s $1 ${TMPDIR}/`basename $1`
- TARGET1="${TARGET1} `basename $1`"
- ;;
- *.rtf ) # RTF files.
- if test -r "$1" ; then
- RTF="${RTF} $1"
- fi
- ;;
- * ) # File or addressee.
- if test -r "$1" ; then
- # ln -s $1 ${TMPDIR}/`basename $1`
- TARGET="${TARGET} $1"
- SUBJECT="${SUBJECT} $1"
- else
- ADDRESSEE="${ADDRESSEE} $1"
- fi
- ;;
- esac
- shift
- done
-
- if test -n "${OVERRIDE_SUBJECT}" ; then
- SUBJECT="${OVERRIDE_SUBJECT}"
- fi
- #
- # Quit if no addressee specified on command line.
- #
- if test -z "${ADDRESSEE}" ; then
- echo "${PROG}: No recipient." >&2
- echo "${USAGE}" >&2
- exit 1
- fi
-
-
- #
- # Create index.rtf file that includes MAILMESSAGE text.
- #
-
- if test -z "${RTF}" ; then
- cat << EOF >> ${INDEX}
- {\rtf0\ansi{\fonttbl\f0\fswiss Helvetica;}
- \margl120
- \margr120
- \pard\tx533\tx1067\tx1601\tx2135\tx2668\tx3202\tx3736\tx4270\tx4803\tx5337\f0\b0\i0\ul0\fs24
- ${MAILMESSAGE}
- EOF
- else
- echo -n '' > ${INDEX}
- for x in ${RTF} ; do
- cat $x >> ${INDEX}
- done
- fi
-
- #
- # Cycle through TARGET list and append attachment lines to index.rtf file.
- #
- for x in ${TARGET} ${TARGET1}; do
- case $x in
- * )
- echo "{{\attachment0 $x" >> ${INDEX}
- echo "}" >> ${INDEX}
- ;;
- esac
- done
-
- echo "" >> ${INDEX}
-
- #
- # Print an informative status message on stderr.
- #
- echo ${PROG}: Bundling ${TARGET:-message} for shipment via NeXTmail to ${ADDRESSEE}. >&2
-
- #
- # Create a tar'ed | compressed .attach file.
- #
- ${TAR} ${TARGET} -C ${TMPDIR} index.rtf ${TARGET1} | compress > ${ATTACH}
-
- #
- # Go into the temporary folder.
- #
- cd ${TMPDIR}
-
- #
- # Uuencode .attach file and give it a .tar.nnnn. prefix.
- #
- ${UUENCODE} ${ATTACH} .tar.$$.${TARFILE} > ${TMPFILE}
-
- #
- # Add the Next-Attachment keyword.
- #
-
- echo "Next-Attachment: .tar.$$.${TARFILE}, `wc -c ${ATTACH} | ${AWK} '{print $1}'`, 1/1, 9999, 0" > ${ATTACH}
- echo "${RR}" >> ${ATTACH}
- echo "Subject: ${SUBJECT}" >> ${ATTACH}
- if test -n "${REPLYTO}" ; then
- echo "Reply-to: ${REPLYTO}" >> ${ATTACH}
- fi
- if test -n "${BULK}" ; then
- echo "Precedence: bulk" >> ${ATTACH}
- fi
- echo "" >> ${ATTACH}
-
- #
- # Append the uuencoded file.
- #
- ${CAT} ${TMPFILE} >> ${ATTACH}
-
- #
- # Deliver the mail via e-mail.
- #
- # ${MAIL} ${VERBOSE} -s "${SUBJECT}" ${ADDRESSEE} < ${ATTACH}
- cat ${ATTACH} | /usr/lib/sendmail ${VERBOSE} -odb -oi ${FROM} ${ADDRESSEE}
-
- exit $?
-
- #
- # $Header: /Net/friday/Users/Source/Next/RCS/next-mail,v 1.7 1993/08/22 19:23:56 treed Exp $
- # Locker: $Locker: $
- # Author and Modification Date: $Author: treed $ $Date: 1993/08/22 19:23:56 $
- # File name and Description:
- # Send NeXTmail(tm) from the command line. This script can be used from a Next or
- # non-Next computer. You may specify files and folders to send and recipients
- # to receive the e-mail; if the thing on the command line is not a folder or file,
- # then next-mail assumes that it is a recipient. You may also specify a '-' and
- # type accompanying e-mail text when prompted.
- #
- # Feel free to distribute this script, just don't charge money for it.
- # Timothy Reed <treed@gun.com>
- #
- # Copyright (c) 1991 Timothy Reed. All rights reserved.
- # WARNING: You may use and distribute this software, but you use it at your own risk.
- #
- # 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.
- # This software comes with ABSOLUTELY NO WARRANTY.
- #
- # Stephen Perkins - 4/13/96
- # Modified to accept relative and absolute pathnames
- #
-