: script to submit a file as a piece of work to a teacher Mailer=/bin/mailx # OK for suns and IBM AIXs # Mailer=/usr/sbin/Mail # good for SGIs whoto1=dick class=CS202 echo "Preparing to send message to $whoto1" echo "Tap CTRL/C to cancel" subject=${1:-unknown} if [ x"$subject" = xunknown ] then echo "Please input a subject: " read subject fi if [ x"$subject" = x ] then echo "Messages without a subject can not be submitted" exit 1 fi file=${2:-"$subject"} # default: subject is also file... if [ x"$file" = xunknown -o ! -r "$file" -o ! -t 0 ] then if [ x"$file" != xunknown -a ! -r "$file" ] then echo $file is not readable or does not exist file=unknown else echo $file will be submitted echo " (Long lines will be word wrapped)" fi if [ x"$file" = xunknown -a -t 0 ] then echo "Please input your posting ending with CTRL/D on a new line" echo " (Tap CTRL/C to cancel message)" echo " (Long lines will be word wrapped)" echo "Subject: $class: $subject" else echo "Reading your message from standard input..." fi tmpfile=/tmp/submit$$ trap "rm $tmpfile" 0 1 2 3 br >$tmpfile if [ -s $tmpfile ] then sed '/^From /s/^/> /'<$tmpfile|$Mailer -s "$class: $subject" $LOGNAME $whoto echo "Thank you, message sent. You will also get a copy." else echo "Empty message not sent" fi else echo "submitting message with subject \"$subject\" from file $file" br <$file | sed '/^From /s/^/> /' |$Mailer -s "$class: $subject" $LOGNAME $whoto1 echo "Thank you, message sent. You will also get a copy." fi