Non-csh addcal script
Ron Heiby
djmolny at wnuxb.UUCP
Sat Aug 4 01:13:40 AEST 1984
I was very impressed by the calend distribution a couple of weeks ago.
I wanted to use it, (and csh isn't a universally available), so I re-wrote
the addcal csh script into ksh (Yes, I know that it's not universally
available, either. See your account rep.) As far as I have been able
to determine, the only thing that the script uses that isn't in sh is
the "set -o noglob" or equivalent. (I think that "set -f" in the
System V Rel. 2 /bin/sh does the same thing, but am not sure.) I
included it because the csh version did it. I am not convinced that
it is necessary. Anyhow, have fun. (Copyright notices were present
in the distribution package, but not in the addcal script. The lack
of notice in the script is maintained in this version.)
---------------------cutcutcutcutcutcutcut--------------------------
#! /bin/ksh
#set -vx
rcfile=$HOME/.calrc remtime="" movo="" movc="" mov="" remc=""
set -o noglob
if [ x$1 != x ]
then
rcfile=$1
fi
echo "Flags [<ra1mxd] \c" ; read flgs
while [ "$flgs" = '?' -o "$flgs" = "" ]
do
echo "Flags:"
echo "< - use alternate dates file"
echo "r - remind at certain time"
echo "a - print always during period"
echo "1 - print once during period" ; echo "m - send mail"
echo "x - execute program - a,1 say how often"
echo "d - delete when finished" ; echo ""
echo "Flags [ra1mxd] \c" ; read flgs
done
echo $flgs | grep -s "<" >/dev/null
if [ $? = 0 ]
then
echo "Alternate file: \c"; read altfile
while [ "$altfile" = '?' -o "$altfile" = "" ]
do
echo "The alternate file will be used as another dates file."
echo "Alternate file: \c"; read altfile
done
echo "< $altfile"
echo "< $altfile" >> $rcfile
exit 0
fi
echo $flgs | grep -s "r" >/dev/null
if [ $? = 0 ]
then
echo "Remind time [hhmm]: \c"
remc=" "
read remtime
while [ "$remtime" = '?' ]
do
echo "Remind expects a four digit time, i.e. 2330."
echo "Remind time [hhmm]: \c" ; read remtime
done
fi
echo $flgs | grep -s "d" >/dev/null
if [ $? = 1 ]
then
echo "Move forward [+<num>]: \c"
movc=""
read mov
while [ "$mov" = '?' ]
do
echo "Enter months and days, eg: +3m2d, +14d, +1m"
echo "Move forward [+<num>]: \c"
read mov
done
echo $mov | egrep "^\+" >/dev/null
if [ $? = 1 ]
then
if [ "$mov" != no -a "$mov" != n -a "$mov" != "" ]
then
echo "bad date - $mov."
mov=""
fi
fi
if [ "$mov" != "" ]
then
movo="+"
movc=" "
fi
fi
echo "Start date: \c" ; read date1
while [ "$date1" = '?' ]
do
echo "Enter starting date; default is '*'"
echo "Start date: \c" ; read date1
done
if [ "$date1" = "" ]
then
date1="*"
fi
echo "End date: \c" ; read date2
while [ "$date2" = '?' ]
do
echo "Enter ending date; default is '*'"
echo "End date: \c" ; read date2
done
if [ "$date2" = "" ]
then
date2="*"
fi
if [ "$date1$date2" = "**" ]
then
echo "No dates given."
exit 1
fi
echo $flgs | grep -s "x" >/dev/null
if [ $? = 0 ]
then
cmd=1
echo "Command: \c"
else
echo "Message: \c"
fi
read msg
while [ "$msg" = '?' -o "$msg" = "" ]
do
if [ ${cmd:-0} = 1 ]
then
echo "Enter command to be executed between $date1 and $date2"
echo "Command: \c"
else
echo "Any message you want printed between $date1 and $date2"
echo "Message: \c"
fi
read msg
done
echo "$flgs$movo $date1 $date2 $mov$movc$remtime$remc$msg"
echo "$flgs$movo $date1 $date2 $mov$movc$remtime$remc$msg" >>$rcfile
------------------------cutcutcutcutcutcutcut----------------------------
--
________________
| __________ | from the overlapping windows
| | ksh! | | of
| |__________ |
| | gmacs! | | Ronald W. Heiby
| | _________ | AT&T Technologies, Inc.
| | |dstar! | | Lisle, IL (CU-D21)
| | | | | __ ...!ihnp4!wnuxa!heiby
| --| | |_/ \_____
| --------- | /\ \_
| | \/ \+++
|TTY_______5620| / \
---------------- (red)
\___/
More information about the Comp.sources.unix
mailing list