#!/bin/sh # Copyright (c) 1991 Bell Communications Research, Inc. (Bellcore) # # Permission to use, copy, modify, and distribute this material # for any purpose and without fee is hereby granted, provided # that the above copyright notice and this permission notice # appear in all copies, and that the name of Bellcore not be # used in advertising or publicity pertaining to this # material without the specific, prior written permission # of an authorized representative of Bellcore. BELLCORE # MAKES NO REPRESENTATIONS ABOUT THE ACCURACY OR SUITABILITY # OF THIS MATERIAL FOR ANY PURPOSE. IT IS PROVIDED "AS IS", # WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. # Conversion from C shell to Bourne shell by Z-Code Software Corp. # Conversion Copyright (c) 1992 Z-Code Software Corp. # Permission to use, copy, modify, and distribute this material # for any purpose and without fee is hereby granted, provided # that the above copyright notice and this permission notice # appear in all copies, and that the name of Z-Code Software not # be used in advertising or publicity pertaining to this # material without the specific, prior written permission # of an authorized representative of Z-Code. Z-CODE SOFTWARE # MAKES NO REPRESENTATIONS ABOUT THE ACCURACY OR SUITABILITY # OF THIS MATERIAL FOR ANY PURPOSE. IT IS PROVIDED "AS IS", # WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. # Brought into line with metamail 2.7 beta release Csh version # Dave Shield February 1994 if test -f /usr/sbin/sendmail then MAILCOMMAND=/usr/sbin/sendmail else MAILCOMMAND=/bin/mail fi if test "$#" -lt 3 then echo "Usage: showexternal body-file access-type name [site [directory [mode]]]" exit 1 fi if [ -z "$METAMAIL_TMPDIR" ] then METAMAIL_TMPDIR=/tmp fi if [ -n "$METAMAIL_PAGER" ] then PAGER="$METAMAIL_PAGER" fi # Check argument integrity. Don't trust mail headers case "$1$2$3$4$5$6$7" in *[\ \ ]*) echo "Illegal white space in arguments -- possibly a mail bomb?\!" echo "Command was:" echo \'$0\' \'$1\' \'$2\' \'$3\' \'$4\' \'$5\' \'$6\' \'$7\' exit 2 esac bodyfile="$1" atype=`echo $2 | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` name="$3" site="$4" dir="$5" mode="$6" server="$7" if test -z "$server" -a $atype = "mail-server" then server=${name}@${site} echo "WARNING -- old style mailserver syntax, using server $server" fi ctype=`grep -i content-type: $bodyfile | sed -e 's/............: //'` if test -z "$ctype" then ctype="text/plain" fi cenc=`grep -i content-transfer-encoding: $bodyfile | sed -e 's/.........................: //'` username="" pass="" TMPDIR=$METAMAIL_TMPDIR/XXXternal.$$ trap "cd $METAMAIL_TMPDIR/ ; rm -rf $TMPDIR" 1 2 3 7 13 15 mkdir $TMPDIR || exit 1 PUSHED_DIR=`pwd` cd $TMPDIR NEWNAME="mm.ext.$$" NEEDSCONFIRMATION=1 case $atype in anon-ftp) echo "This mail message contains a POINTER (reference) to data that is " echo not included in the message itself. Rather, the data can be retrieved echo automatically using anonymous FTP to a site on the network. ;; ftp) echo "This mail message contains a POINTER (reference) to data that is " echo not included in the message itself. Rather, the data can be retrieved echo automatically using the FTP protocol to a site on the network. ;; mail-server) if [ -n "`type -p mktemp`" ] ; then TmpExtJunk=`mktemp ${METAMAIL_TMPDIR}/ext.junk.$$.XXXXXX` || exit 1 else TmpExtJunk=${METAMAIL_TMPDIR}/ext.junk.$$ rm -f $TmpExtJunk fi set -f cat > $TmpExtJunk <> $TmpExtJunk if [ -n "$PAGER" ] ; then $PAGER $TmpExtJunk else more $TmpExtJunk fi rm $TmpExtJunk ;; *) NEEDSCONFIRMATION=0 ;; esac if test $NEEDSCONFIRMATION -ne 0 then echo "" echo -n "Do you want to proceed with retrieving the external data? [y] " read ANS case "$ANS" in [Nn]*) cd $METAMAIL_TMPDIR rm -rf $TMPDIR; exit 0 ;; esac fi case "$atype" in anon-ftp | ftp) case "$atype" in anon-ftp ) username=anonymous pass=`whoami`@`hostname -f` ;; esac if test -z "$site" then echo -n "Site for ftp access: " read site fi if test -z "$username" then echo -n "User name at site ${site}: " read username fi if test -z "$pass" then echo -n "Password for user $username at site ${site}: " stty -echo read pass stty echo echo "" fi if test -z "$dir" then DIRCMD="" else DIRCMD="cd $dir" fi if test -z "$mode" then MODECMD="" else MODECMD="type $mode" fi echo OBTAINING MESSAGE BODY USING FTP echo SITE: $site USER: $username if [ -n "`type -p mktemp`" ] ; then TmpFtp=`mktemp ${METAMAIL_TMPDIR}/mm.ftp.$$.XXXXXX` || exit 1 else TmpFtp=${METAMAIL_TMPDIR}/mm.ftp.$$ rm -f $TmpFtp fi set -f cat > $TmpFtp < $NEWNAME echo To: "$server" >> $NEWNAME echo "" >> $NEWNAME sed -e 1,/^\$/d < $bodyfile >> $NEWNAME $MAILCOMMAND -t < $NEWNAME if test $? -ne 0 then echo sendmail failed cd $METAMAIL_TMPDIR rm -rf $TMPDIR exit 1 fi cd $METAMAIL_TMPDIR rm -rf $TMPDIR echo Your $ctype data has been requested from a mail server. exit 0 ;; *) echo UNRECOGNIZED ACCESS-TYPE cd $METAMAIL_TMPDIR rm -rf $TMPDIR exit 1 ;; esac if test "$cenc" = base64 then mimencode -u -b < $NEWNAME > OUT mv OUT $NEWNAME elif test "$cenc" = quoted-printable then mimencode -u -q < $NEWNAME > OUT mv OUT $NEWNAME fi cd $PUSHED_DIR case "$atype" in local-file ) metamail -b -p -c $ctype $NEWNAME ;; * ) metamail -b -p -c "$ctype" $TMPDIR/$NEWNAME ;; esac if test $? -ne 0 then echo metamail failed cd $METAMAIL_TMPDIR rm -rf $TMPDIR exit 1 fi if test ! "$NEWNAME" = "$name" then echo "" echo The data just displayed is stored in the file $TMPDIR/$NEWNAME echo "Do you want to delete it?" rm -i $TMPDIR/$NEWNAME fi if test ! -r ${TMPDIR}/${NEWNAME} then cd / cd $METAMAIL_TMPDIR rmdir $TMPDIR fi