home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1999 March B
/
SCO_CASTOR4RRT.iso
/
base
/
root.15
/
usr
/
bin
/
metasend
/
metasend~
Wrap
Text File
|
1998-08-19
|
11KB
|
419 lines
#!/bin/sh
# The following was generated from
# NLS/en/metamail.gen
#
MF_METAMAIL=metamail.cat@mail
#
MS_EXTCOMPOSE=1
EXTCOMPOSE_MSG_WHERE=1
EXTCOMPOSE_MSG_LOCAL=2
EXTCOMPOSE_MSG_AFS=3
EXTCOMPOSE_MSG_ANON=4
EXTCOMPOSE_MSG_LOGIN=5
EXTCOMPOSE_MSG_MAILSRVR=6
EXTCOMPOSE_MSG_NUMBER=7
EXTCOMPOSE_MSG_DOMAIN=8
EXTCOMPOSE_MSG_DIR=9
EXTCOMPOSE_MSG_NAME=10
EXTCOMPOSE_MSG_TRANSFER=11
EXTCOMPOSE_MSG_PATH=12
EXTCOMPOSE_MSG_ADDR=13
EXTCOMPOSE_MSG_ACCESS=14
EXTCOMPOSE_MSG_CONTENT=15
EXTCOMPOSE_MSG_ENCODED=16
EXTCOMPOSE_MSG_NOT=17
EXTCOMPOSE_MSG_BASE64=18
EXTCOMPOSE_MSG_QP=19
EXTCOMPOSE_MSG_UUENCODE=20
EXTCOMPOSE_MSG_DATA=21
EXTCOMPOSE_ERR_USAGE=22
EXTCOMPOSE_ERR_CHOICE=23
EXTCOMPOSE_ERR_EXIST=24
#
MS_GETFILENAME=2
GETFILENAME_MSG_NAME=1
GETFILENAME_ERR_NO_FILE=2
#
MS_METASEND=3
METASEND_MSG_TO=1
METASEND_MSG_SUBJECT=2
METASEND_MSG_CC=3
METASEND_MSG_CONTENT=4
METASEND_MSG_FILE=5
METASEND_MSG_ENC=6
METASEND_MSG_NO=7
METASEND_MSG_BASE64=8
METASEND_MSG_QP=9
METASEND_MSG_UUENCODE=10
METASEND_ERR_S=11
METASEND_ERR_C=12
METASEND_ERR_SUB=13
METASEND_ERR_T=14
METASEND_ERR_E=15
METASEND_ERR_F=16
METASEND_ERR_M=17
METASEND_ERR_OPTION=18
METASEND_ERR_FILE=19
METASEND_ERR_ANSWER=20
METASEND_ERR_BATCH=21
METASEND_ERR_DATAFILE=22
METASEND_ERR_DELIVERY=23
METASEND_ERR_DRAFT=24
#
MS_SHOWAUDIO=4
SHOWAUDIO_MSG_CHOOSE=1
SHOWAUDIO_MSG_SPEAKER=2
SHOWAUDIO_MSG_TELEPHONE=3
SHOWAUDIO_MSG_PREFER=4
SHOWAUDIO_MSG_USE_PHONE=5
SHOWAUDIO_MSG_FUTURE=6
SHOWAUDIO_MSG_USE_SPEAKER=7
SHOWAUDIO_MSG_SENDING=8
SHOWAUDIO_MSG_AIFF=9
SHOWAUDIO_MSG_NEXT=10
SHOWAUDIO_MSG_DEV=11
SHOWAUDIO_MSG_NUMBER=12
SHOWAUDIO_MSG_CALLING=13
SHOWAUDIO_MSG_DONE=14
SHOWAUDIO_MSG_RSH=15
SHOWAUDIO_MSG_CANT_PLAY=16
#
MS_SHOWEXTERNAL=5
SHOWEXTERNAL_MSG_ANON=1
SHOWEXTERNAL_MSG_FTP=2
SHOWEXTERNAL_MSG_SRVR=3
SHOWEXTERNAL_MSG_DATA=4
SHOWEXTERNAL_MSG_SITE=5
SHOWEXTERNAL_MSG_USER=6
SHOWEXTERNAL_MSG_PASSWD=7
SHOWEXTERNAL_MSG_BODY=8
SHOWEXTERNAL_MSG_SU=9
SHOWEXTERNAL_MSG_GETTING=10
SHOWEXTERNAL_MSG_REQUESTED=11
SHOWEXTERNAL_MSG_RM=12
SHOWEXTERNAL_ERR_NAME=13
SHOWEXTERNAL_ERR_USAGE=14
SHOWEXTERNAL_ERR_FTP=15
SHOWEXTERNAL_ERR_FOUND=16
SHOWEXTERNAL_ERR_BODYFILE=17
SHOWEXTERNAL_ERR_MAIL=18
SHOWEXTERNAL_ERR_TYPE=19
SHOWEXTERNAL_ERR_METAMAIL=20
SHOWEXTERNAL_ERR_ENTER=21
#
MS_SHOWNONASCII=6
SHOWNONASCII_MSG_DISPLAY=1
SHOWNONASCII_MSG_XTERM=2
#
MS_SHOWPARTIAL=7
SHOWPARTIAL_MSG_READ=1
SHOWPARTIAL_MSG_WARN=2
SHOWPARTIAL_MSG_SEV=3
SHOWPARTIAL_MSG_TOTAL=4
SHOWPARTIAL_MSG_FULL=5
SHOWPARTIAL_ERR_USAGE=6
SHOWPARTIAL_ERR_TREEROOT=7
SHOWPARTIAL_ERR_ID=8
SHOWPARTIAL_ERR_CP=9
#
MS_SHOWPICTURE=8
SHOWPICTURE_MSG_DISPLAY=1
SHOWPICTURE_MSG_NOTE=2
# Copyright (c) 1998 The Santa Cruz Operation, Inc.. All Rights Reserved.
#
# THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF THE
# SANTA CRUZ OPERATION INC.
#
# The copyright notice above does not evidence any actual or intended
# publication of such source code.
#
# ident @(#) metasend.sh 11.2 97/11/03
#
#############################################################################
#
# Copyright (c) 1997 The Santa Cruz Operation, Inc..
# All Rights Reserved.
#
# THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF
# THE SANTA CRUZ OPERATION INC.
# The copyright notice above does not evidence any
# actual or intended publication of such source code.
#
#############################################################################
#
# 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.
#
echo_n()
{
echo "$@\c"
}
:
if [ -z "$METAMAIL_TMPDIR" ]
then METAMAIL_TMPDIR=/tmp
fi
MustDelete=0
batchmode=0
splitsize=100000
while test ! -z "$*"
do
case $1 in
-S) shift
if test -z "$*"
then
dspmsg $MF_METAMAIL -s $MS_METASEND $METASEND_ERR_S \
"-S requires a following argument, the SPLIT threshhold\n" "-S"
exit 1
fi
splitsize=$1
shift ;;
-b) batchmode=1
shift ;;
-c) shift
if test -z "$*"
then
dspmsg $MF_METAMAIL -s $MS_METASEND $METASEND_ERR_C \
"-c requires a following argument, the CC address\n" "-c"
exit 1
fi
cc=$1
shift ;;
-s) shift
if test -z "$*"
then
dspmsg $MF_METAMAIL -s $MS_METASEND $METASEND_ERR_SUB \
"-s requires a following argument, the SUBJECT\n" "-s"
exit 1
fi
subject=$1
shift ;;
-t) shift
if test -z "$*"
then
dspmsg $MF_METAMAIL -s $MS_METASEND $METASEND_ERR_T \
"-t requires a following argument, the TO address\n" "-t"
exit 1
fi
to=$1
shift ;;
-e) shift
if test -z "$*"
then
dspmsg $MF_METAMAIL -s $MS_METASEND $METASEND_ERR_E \
"-e requires a following argument, the ENCODING value\n" "-e"
exit 1
fi
encode=$1
shift ;;
-f) shift
if test -z "$*"
then
dspmsg $MF_METAMAIL -s $MS_METASEND $METASEND_ERR_F \
"-f requires a following argument, the DATA FILE\n" "-f"
exit 1
fi
datafile=$1
shift ;;
-m) shift
if test -z "$*"
then
dspmsg $MF_METAMAIL -s $MS_METASEND $METASEND_ERR_M \
"-m requires a following argument, the MIME CONTENT-TYPE\n" "-m"
exit 1
fi
ctype=$1
shift ;;
-z) MustDelete=1
shift ;;
*) dspmsg $MF_METAMAIL -s $MS_METASEND $METASEND_ERR_OPTION \
"UNRECOGNIZED METASEND OPTION: $1\n" "$1"
exit 1 ;;
esac
done
if test $batchmode -eq 0
then
if test -z "${to:-}"
then
dspmsg $MF_METAMAIL -s $MS_METASEND $METASEND_MSG_TO "To: "
read to
fi
if test -z "${subject:-}"
then
dspmsg $MF_METAMAIL -s $MS_METASEND $METASEND_MSG_SUBJECT \
"Subject: "
read subject
fi
if test -z "${cc:-}"
then
dspmsg $MF_METAMAIL -s $MS_METASEND $METASEND_MSG_CC "CC: "
read cc
fi
if test -z "${ctype:-}"
then
dspmsg $MF_METAMAIL -s $MS_METASEND $METASEND_MSG_CONTENT \
"Content-type: "
read ctype
fi
if test -z "${datafile:-}"
then
looping=1
while test $looping -eq 1
do
dspmsg $MF_METAMAIL -s $MS_METASEND $METASEND_MSG_FILE \
"Name of file containing $ctype data: " "$ctype"
read datafile
if test -r "$datafile"
then
looping=0
else
dspmsg $MF_METAMAIL -s $MS_METASEND \
$METASEND_ERR_FILE \
"The file $datafile does not exist.\n" \
"$datafile"
fi
done
fi
if test -z "${encode:-}"
then
looping=1
while test $looping -eq 1
do
dspmsg $MF_METAMAIL -s $MS_METASEND $METASEND_MSG_ENC \
"Do you want to encode this data for sending through the mail?\n"
dspmsg $MF_METAMAIL -s $MS_METASEND $METASEND_MSG_NO \
" 1 -- No, it is already in 7 bit ASCII\n"
dspmsg $MF_METAMAIL -s $MS_METASEND $METASEND_MSG_BASE64 \
" 2 -- Yes, encode in base64 (most efficient)\n"
dspmsg $MF_METAMAIL -s $MS_METASEND $METASEND_MSG_QP \
" 3 -- Yes, encode in quoted-printable (less efficient, more readable)\n"
dspmsg $MF_METAMAIL -s $MS_METASEND $METASEND_MSG_UUENCODE \
" 4 -- Yes, encode it using uuencode (not standard, being phased out)\n"
read encode
looping=0
case "$encode" in
1) encodingprog=cat
encode=7bit ;;
2) encodingprog="mimencode -b"
encode=base64 ;;
3) encodingprog="mimencode -q"
encode=quoted-printable ;;
4) encodingprog="uuencode $datafile"
encode=x-uue ;;
*) dspmsg $MF_METAMAIL -s $MS_METASEND \
$METASEND_ERR_ANSWER \
"Unrecognized answer, please try again.\n"
looping=1 ;;
esac
done
fi
else
if test -z "${to:-}" \
-o -z "${subject:-}" \
-o -z "${ctype:-}" \
-o -z "${datafile:-}"
then
dspmsg $MF_METAMAIL -s $MS_METASEND $METASEND_ERR_BATCH \
"metasend: in batch mode, -t, -s, -f, and -m are all required\n" \
"-t" "-s" "-f" "-m"
exit 1
fi
if test ! -r "$datafile"
then
dspmsg $MF_METAMAIL -s $MS_METASEND $METASEND_ERR_DATAFILE \
"metasend: The file $datafile does not exist\n" "$datafile"
exit 1
fi
if test -z "${cc:-}"
then
cc=''
fi
if test -z "${encode:-}"
then
case "$ctype" in
text*) encodingprog="mimencode -q"
encode=quoted-printable ;;
*) encodingprog="mimencode -b"
encode=base64 ;;
esac
else
case "$encode" in
base64) encodingprog="mimencode -b" ;;
x-uue) encodingprog="uuencode $datafile" ;;
*) encodingprog="mimencode -q"
encode=quoted-printable ;;
esac
fi
fi
fname=$METAMAIL_TMPDIR/metasend.$$
echo "To: $to" > $fname
echo "Subject: $subject" >> $fname
echo "CC: $cc" >> $fname
echo "MIME-Version: 1.0" >> $fname
echo "Content-type: $ctype" >> $fname
echo "Content-Transfer-Encoding: $encode" >> $fname
echo "" >> $fname
$encodingprog < "$datafile" >> "$fname"
# Ensure last line has trailing carriage return
echo "" >> "$fname"
splitmail -s $splitsize -d $fname
if test $? -eq 0
then
rm -f $fname
elif test "$MustDelete" -eq 1
then
dspmsg $MF_METAMAIL -s $MS_METASEND $METASEND_ERR_DELIVERY \
"Mail delivery failed\n"
rm -f $fname
else
dspmsg $MF_METAMAIL -s $MS_METASEND $METASEND_ERR_DRAFT \
"Mail delivery failed, draft mail is in $fname\n" "$fname"
fi