Cover V04, I06
Article
Listing 1
Listing 2
Listing 3
Listing 4
Listing 5

nov95.tar


Listing 5: A sample desktop menu system

# Listing 5
# menutxt - the menu text file for the "automated desktop" menu
#
<menuheader p>clear
<menuheader p>echo
<menuheader p>DATE=`date|awk '{print $1 " " $2 " " $3}'`
<menuheader p>TIME=`date|awk '{print $4}'|cut -c1-5`
<menuheader p>USER=`who am i|awk '{print $1}'`
<menuheader p>MAILMSG=`grep Message-Id: $MAIL|wc -l`
<menuheader p>echo $DATE $TIME|awk '{ printf("DATE: %-4s%-4s%-45sTIME: %-5s\n", $1,
$2, $3, $4) }'
<menuheader p>echo $MAILMSG $USER|awk '{ printf("MAIL: %-53sUSER: %-15s\n", $1, $2)
}'
<menuheader p>echo "exit" > formkey
<menuheader p>exit 0
<mainmenu p>forms menuheader /etc/menutxt
<mainmenu p>echo "main" > formkey
<mainmenu p>exit 0
<main>
<main>                           AUTOMATED DESKTOP
<main>
<main>                             1. CALENDAR
<main>
<main>                             2. CALCULATOR
<main>
<main>                             3. MESSAGE MENU
<main>
<main>                             4. MAIL MENU
<main>
<main>                             9. EXIT
<main>
<main p>echo
<main p>echo "                       ENTER THE SELECTION NUMBER: \c"
<main p>read SELECT
<main p>case "$SELECT" in
<main p>
<main p>     1 ) clear;
<main p>         cal `date|cut -d " " -f6`|pg;
<main p>         echo "mainmenu" > formkey;
<main p>         exit 0
<main p>         ;;
<main p>
<main p> H1|h1 ) clear;
<main p>         man cal|pg;
<main p>         echo "mainmenu" > formkey;
<main p>         exit 0
<main p>         ;;
<main p>
<main p>     2 ) clear;
<main p>         echo "Calculator is now on. Press Ctrl-d to exit . . .";
<main p>         bc;
<main p>         echo "mainmenu" > formkey;
<main p>         exit 0
<main p>         ;;
<main p>
<main p> H2|h2 ) clear;
<main p>         man bc|pg;
<main p>         echo "mainmenu" > formkey;
<main p>         exit 0
<main p>         ;;
<main p>
<main p>     3 ) clear;
<main p>         echo "mesgmenu" > formkey;
<main p>         exit 0
<main p>         ;;
<main p>
<main p> H3|h3 ) clear;
<main p>         man write|pg;
<main p>         echo "mainmenu" > formkey;
<main p>         exit 0
<main p>         ;;
<main p>
<main p>     4 ) clear;
<main p>         echo "mailmenu" > formkey;
<main p>         exit 0
<main p>         ;;
<main p>
<main p> H4|h4 ) clear;
<main p>         man mail|pg;
<main p>         echo "mainmenu" > formkey;
<main p>         exit 0
<main p>         ;;
<main p>
<main p>     9 ) clear;
<main p>         echo "exit" > formkey;
<main p>         exit 0
<main p>         ;;
<main p>
<main p>     * ) clear;
<main p>         echo "mainmenu" > formkey;
<main p>         exit 0
<main p>         ;;
<main p>
<main p>esac
<mesgmenu p>forms menuheader /etc/menutxt
<mesgmenu p>echo "mesg" > formkey
<mesg>
<mesg>
<mesg>
<mesg>
<mesg>                                MESSAGE MENU
<mesg>
<mesg>                             1. SEND MESSAGE
<mesg>
<mesg>                             2. PERMIT MESSAGES
<mesg>
<mesg>                             3. DENY MESSAGES
<mesg>
<mesg>                             9. EXIT
<mesg>
<mesg p>echo
<mesg p>echo "                       ENTER THE SELECTION NUMBER: \c"
<mesg p>read SELECT
<mesg p>case "$SELECT" in
<mesg p>
<mesg p>     1 ) clear;
<mesg p>         who;
<mesg p>         echo;
<mesg p>         echo "Enter user id: \c";
<mesg p>         read USERID;
<mesg p>         write $USERID;
<mesg p>         echo "mesgmenu" > formkey;
<mesg p>         exit 0
<mesg p>         ;;
<mesg p>
<mesg p> H1|h1 ) clear;
<mesg p>         man write|pg;
<mesg p>         echo "mesgmenu" > formkey;
<mesg p>         exit 0
<mesg p>         ;;
<mesg p>
<mesg p>     2 ) clear;
<mesg p>         mesg y;
<mesg p>         echo "MESSAGE RECEPTION TURNED ON";
<mesg p>         echo;
<mesg p>         echo "Press return to continue... \c";
<mesg p>         read RETURN;
<mesg p>         echo "mesgmenu" > formkey;
<mesg p>         exit 0
<mesg p>         ;;
<mesg p>
<mesg p>     3 ) clear;
<mesg p>         mesg n;
<mesg p>         echo "MESSAGE RECEPTION TURNED OFF";
<mesg p>         echo;
<mesg p>         echo "Press return to continue... \c";
<mesg p>         read RETURN;
<mesg p>         echo "mesgmenu" > formkey;
<mesg p>         exit 0
<mesg p>         ;;
<mesg p>
<mesg p>     9 ) clear;
<mesg p>         echo "mainmenu" > formkey;
<mesg p>         exit 0
<mesg p>         ;;
<mesg p>
<mesg p>     * ) clear;
<mesg p>         echo "mesgmenu" > formkey;
<mesg p>         exit 0
<mesg p>         ;;
<mesg p>
<mesg p>esac
<mailmenu p>forms menuheader /etc/menutxt
<mailmenu p>echo "mail" > formkey
<mail>
<mail>
<mail>
<mail>
<mail>                               MAIL MENU
<mail>
<mail>                             1. SEND MAIL
<mail>
<mail>                             2. READ MAIL
<mail>
<mail>                             9. EXIT
<mail>
<mail p>echo
<mail p>echo "                       ENTER THE SELECTION NUMBER: \c"
<mail p>read SELECT
<mail p>case "$SELECT" in
<mail p>
<mail p>     1 ) clear;
<mail p>         ls -x /users;
<mail p>         echo "Enter user id: \c";
<mail p>         read USERID;
<mail p>         mail $USERID;
<mail p>         echo "mailmenu" > formkey;
<mail p>         exit 0
<mail p>         ;;
<mail p>
<mail p> H1|h1 ) clear;
<mail p>         echo "mailhelp" > formkey;
<mail p>         exit 0
<mail p>         ;;
<mail p>
<mail p>     2 ) clear;
<mail p>         mail;
<mail p>         echo "mailmenu" > formkey;
<mail p>         exit 0
<mail p>         ;;
<mail p>
<mail p>     9 ) clear;
<mail p>         echo "mainmenu" > formkey;
<mail p>         exit 0
<mail p>         ;;
<mail p>
<mail p>     * ) clear;
<mail p>         echo "mailmenu" > formkey;
<mail p>         exit 0
<mail p>         ;;
<mail p>
<mail p>esac
<mailhelp>Send and receive mail:
<mailhelp>
<mailhelp>The users listed are those contained is the /user directory.
<mailhelp>
<mailhelp>Electronic mail requires the availability of sendmail and a
<mailhelp>uucp or internet connection.
<mailhelp>
<mailhelp>If you have internet access and wish to send mail to a user
<mailhelp>at another site use the address format: user@remotehost.domain
<mailhelp p>echo
<mailhelp p>echo "Press return to continue... \c"
<mailhelp p>read RETURN
<mailhelp p>echo "mailmenu" > formkey
<mailhelp p>exit 0