Cover V02, I02
Article
Listing 1
Listing 2
Listing 3
Listing 4
Listing 5
Listing 6
Listing 7

mar93.tar


Listing 7: maxedit -- Makes it easy to edit maxtabs (and crontabls)

:
######################################################
# maxedit - this is a maxtab/crontab utility
# maxedit uses vi to edit a maxtab file.  maxedit
# calls maxtab, writes the results to temp file, then
# lets you edit the temp file.  After leaving vi you
# are asked if you would like to update our maxtab
# file.
######################################################

tmpfile=/tmp/maxedit.$$

myname=`basename $0`
case "$myname" in
maxedit) progtab=maxtab ;;
cronedit) progtab=crontab ;;
*) echo "Error: who am I?"; exit 1 ;;
esac

# always try to cleanup.  there are three ways to exit:
# maxtab may fail, vi may be killed, or the user may
# press the Del key.

trap 'rm -f $tmpfile ; exit 1' 0 1 2 3 15

# stop on the first error
set -e

$progtab -l > $tmpfile
vi $tmpfile

echo "Update $progtab? (y/n)[y]: \c"
read reply
case "$reply" in
[nN]|[nN][oO]) rm -f $tmpfile ; exit 1 ;;
*) ;;
esac

$progtab < $tmpfile
rm -f $tmpfile
exit 0