#!/bin/sh
# @(#) subm 1.1 Delta: 95/04/21 16:19:06 Extraction: 95/04/21 16:19:29 @(#)
trap "rm -f /tmp/msg.$$ 2>/dev/null" 0 2 3 4 5 6 7 8 10 12 13 15
if [ $# -eq 0 ]
then
  echo "program name not specified"
  exit 1
fi
who=`who am i | awk '{print $1;}'`
start="`date`"
short=`basename $1`
time $* 1>log.$short.$$ 2>&1
code=$?
echo "$1 (pid $$) command: $*" > /tmp/msg.$$
echo "$1 (pid $$) started  $start." >> /tmp/msg.$$
echo "$1 (pid $$) finished `date` with status $code." >> /tmp/msg.$$
cat /tmp/msg.$$ >>log.$short.$$
if write $who < /tmp/msg.$$ 2>/dev/null
then
  :
else
  PATH=/bin:/usr/bin mail $who </tmp/msg.$$
fi
rm /tmp/msg.$$
