EASY, a menu driven front end for UNIX

Danny Shaw danny at neptune.iex.com
Tue Feb 12 09:44:11 AEST 1991


This is a very early attempt I had at a menu driven UNIX front end for
novice users.

It is written in ksh. Sorry haven't had time to port it to sh or csh
Put the file easy in /usr/local/bin.
Put the file easy.h and easy.time in /usr/local/bin.
type % easy
You will probably need to modify the Main menu to use something other than
ELM, RN, and Tsheet.
It is in no way Guaranteed, all liabilities are that of the user.
Feel free to Modify in any way.

Mail me suggestions or comments as to how it could be better.

There will be three files to cut out.
1. easy
2. easy.h
3. easy.time

+++++++++++++++++++CUT HERE and name it 'easy'++++++++++++++++++++++++++++++++
/usr/local/lib/easy.h 2>/dev/null

+++++++++++++++++++CUT HERE and name it 'easy.h'++++++++++++++++++++++++++++++
 # !/bin/ksh
########################################################################
#########
# A script to help Non-UNIX users move through a Unix environment.
# Written by: Danny Shaw
# Last Modification date: 2/8/91
########################################################################
#########

# Set up variables #

BOLD=`tput smso`
OFF=`tput rmso`
BELL='tput bel'
FNAME=`awk -F":" '$1 == "'$USER'" {print $5} ' /etc/passwd | cut -d" " -f1`
INFO="Type <RETURN> to continue..."
INVALID="Type file name or <q> to return to the menu screen.  ->  "
TIME1='/usr/local/lib/easy.time -1 &'
TIME2='/usr/local/lib/easy.time -2 &'

# Draw the main menu screen #

clear
while true
 do
   clear
   date '+DATE: %m/%d/%y'
   /usr/bin/echo "                             ${BOLD}IEX Corporation${OFF}
                          MENU driven UNIX system." 
   /usr/bin/echo ""
   /usr/bin/echo -n ${FNAME}", Type:
			${BOLD} 1 ${OFF} to read mail (elm)
			
			${BOLD} 2 ${OFF} to read news (rn)

			${BOLD} 3 ${OFF} file/directory management

			${BOLD} 4 ${OFF} Tsheet

			${BOLD} 5 ${OFF} Fortune

			${BOLD} 6 ${OFF} UNIX-SHELL

			${BOLD} q ${OFF} to quit

			- > [    ]"

	eval $TIME1 
    TIMEPID=$!

# If named option is given redefine it to a numarical value #

   read ANS FILE
	case $ANS in
		elm)
			ANS="1"
		;;
		rn)
			ANS="2"
		;;
		[Tt]sheet)
			ANS="4"
		;;
		[Ff]ortune)
			ANS="5"
		;;
		[Uu]*[Xx])
			ANS="6"
		;;
		q)
			ANS="q"
		;;
	esac

# Main menu selections #

   case $ANS in
     1) 
		kill -9 $TIMEPID 
       /usr/bin/echo -n "Read Mail? 
Please answer ${BOLD} Y ${OFF}es or ${BOLD} N ${OFF}o...
       - > "
       $BELL
       while read FILE
         do 
           case $FILE in
             [Nn])
               break
              ;;
             [Yy])
                 if [ $FILE = "q" ]
                   then
                     break
                 else
                   /usr/local/bin/elm
                   break
                 fi
              ;;
           esac
         done
     ;;
     2) 
		kill -9 $TIMEPID
       /usr/bin/echo -n "Read News? 
Please answer ${BOLD} Y ${OFF}es or ${BOLD} N ${OFF}o...
       - > "
       $BELL
       while read FILE
         do 
           case $FILE in
             [Nn])
               break
              ;;
             [Yy])
                 if [ $FILE = "q" ]
                   then
                     break
                 else
                   clear
                   /usr/local/bin/rn
                   break
                 fi
              ;;
           esac
         done
     ;;

# Draw Sub-menu menu screen #

     3) 
		kill -9 $TIMEPID
       clear
       while true
       do
         clear
         date '+DATE: %m/%d/%y'
         /usr/bin/echo "                            FILE MANAGEMENT SYSTEM" 
         /usr/bin/echo
         /usr/bin/echo -n $FNAME", Type:
			${BOLD} 1 ${OFF} to view a file (more)
				
			${BOLD} 2 ${OFF} to edit a file (vi)

			${BOLD} 3 ${OFF} to print a file (lpr)

			${BOLD} 4 ${OFF} to copy a file (cp)
				
			${BOLD} 5 ${OFF} to rename a file (mv)

			${BOLD} 6 ${OFF} to delete a file (rm)

			${BOLD} 7 ${OFF} to list a directory (ls)

			${BOLD} 8 ${OFF} to change directories (cd)

			${BOLD} q ${OFF} to quit to main menu

			- > [    ]"

			eval $TIME2
   			TIMEPID=$!

# If named option is given redefine it to a numarical value #

        read ANS FILE
			case $ANS in
				more)
	   				ANS="1"
				;;
				vi)
					ANS="2"
				;;
				lpr)
					ANS="3"
				;;
				cp)
					ANS="4"
				;;
				mv)
					ANS="5"
				;;
				rm)
					ANS="6"
				;;
				ls)
					ANS="7"
				;;
				cd)
					ANS="8"
				;;
				q)
					ANS="q"
				;;
			esac

# Sub-menu selections for file manipulation #

        case $ANS in
          1)
			kill -9 $TIMEPID
            /usr/bin/echo -n  "view what file?
            - > "
            $BELL
            while read FILE
            do
              if [ -z "$FILE" ]
                then
                clear
                ls -f
                /usr/bin/echo -n $INVALID
                $BELL
              else
                if [ $FILE = "q" ]
                  then
                  break
                else
                  if [ -s $FILE ]
                    then
                    more $FILE
                    /usr/bin/echo -n $INVALID
                  fi
                fi
              fi
            done
            clear
          ;;
          2) 
			kill -9 $TIMEPID
            /usr/bin/echo -n "vi what file?
          - > "
            $BELL -p
            while read FILE
            do
              if [ -z "$FILE" ]
                then
                clear
                ls -f
                /usr/bin/echo -n $INVALID
                $BELL
              else
                if [ $FILE = "q" ]
                  then
                  break
                else
                  if [ -s "$FILE" ]
                    then
                    vi $FILE
                    /usr/bin/echo -n $INVALID
                  fi
                fi
              fi
            done
          ;;
          3)
			kill -9 $TIMEPID
            /usr/bin/echo -n "print what file?
             - > "
            $BELL -p
            while read FILE
            do
              if [ -z "$FILE" ]
                then
                clear
                ls -f
                /usr/bin/echo -n $INVALID
                $BELL
              else
                if [ $FILE = "q" ]
                  then
                  break
                else
                  if [ -s "$FILE" ]
                    then
                    lpr -P$PRINTER $FILE
                    /usr/bin/echo "File has been printed to your default
printer"
                    /usr/bin/echo -n $INVALID
                  fi
                fi
              fi
            done
          ;;
          4)
			kill -9 $TIMEPID
            /usr/bin/echo -n "copy what file?
            - > " 
            $BELL -p
            while read FILE
            do
              if [ -z "$FILE" ]
                then
                clear
                ls -f
                /usr/bin/echo -n $INVALID
                $BELL
              else
                if [ $FILE = "q" ]
                  then
                  break
                else
                  if [ -s "$FILE" ]
                    then
                    /usr/bin/echo -n "Enter the new file name: "
                    read ANS
                    cp $FILE $ANS
                    /usr/bin/echo -n $INVALID
                  fi
                fi
              fi
            done
          ;;
          5)
			kill -9 $TIMEPID
            /usr/bin/echo -n "rename what file?
              - > "
            $BELL -p
            while read FILE
            do
              if [ -z "$FILE" ]
                then
                clear
                ls -f
                /usr/bin/echo -n $INVALID
                $BELL
              else
                if [ $FILE = "q" ]
                  then
                  break
                else
                  if [ -s "$FILE" ]
                    then
                    /usr/bin/echo -n "Enter the new file name: "
                    read ANS
                    mv $FILE $ANS
                    /usr/bin/echo -n $INVALID
                  fi
                fi
              fi
            done
          ;;
          6)
			kill -9 $TIMEPID
            /usr/bin/echo -n "delete what file?
              - > "
            $BELL -p
            while read FILE
            do
              if [ -z "$FILE" ]
                then
                clear
                ls -f
                /usr/bin/echo -n $INVALID
                $BELL
              else
                if [ $FILE = "q" ]
                  then
                  break
                else
                  if [ -s "$FILE" ]
                    then
                    rm $FILE 
                    /usr/bin/echo -n $INVALID
                  fi
                fi
              fi
            done
          ;;
          7)
			kill -9 $TIMEPID
            clear
            ls -Ff
			echo "Current directory is "$PWD
			echo
            /usr/bin/echo -n $INFO
            read ANS
            $BELL
          ;;
          8) 
			kill -9 $TIMEPID
            /usr/bin/echo -n "cd to what directory? 
                  - > "
            $BELL
            while read FILE
            do 
              if [ -z "$FILE" ]
                then
                clear
                ls -Ff
				echo "Current directory is "$PWD
                /usr/bin/echo -n $INVALID
                $BELL
              else
                if [ $FILE = "q" ]
                  then
                  break
                else
                  if [ -d "$FILE" ]
                    then
                    cd $FILE
					echo "Current directory is "$PWD
					echo
                    /usr/bin/echo -n $INVALID
                  fi
                fi
              fi
            done
          ;;
         [qQ]) 
			kill -9 $TIMEPID
              break
          ;;
		 *)	
			kill -9 $TIMEPID
		  ;;
        esac
      done
     ;;
	4) 
		kill -9 $TIMEPID
		/usr/local/bin/tsheet
   		echo $INFO
	;;
	5)
		kill -9 $TIMEPID
		/usr/games/fortune
   		echo $INFO
		read ANS
	;;
	6)
		kill -9 $TIMEPID
		echo "Type 'exit' when you want to leave the UNIX-SHELL"
		echo "Hit <RETURN>..."
		read ANS
		clear
		/bin/csh -i
	;;
    [qQ]) 
		kill -9 $TIMEPID
		        break
     ;;
     *) /usr/bin/echo Sorry that name is not recognized
         /usr/bin/echo $INFO
         /usr/bin/echo WHOOPS
		 read ANS
		kill -9 $TIMEPID
     ;;
   esac
   done
   /usr/bin/echo "See Ya" $FNAME", It has been fun!"
exit

++++++++++++CUT HERE and name it easy.time ++++++++++++++++++++++++++++++++++
for ARG in $*
do case $ARG in
	-1) CURLOC='tput cup 19 29'
	;;
	-2) CURLOC='tput cup 22 29'
	;;
	esac
done
TIMELOC='tput cup 0 63'
HOUR=`date '+%H'`
MIN=`date '+%M'`
SEC=`date '+%S'`
while [ $HOUR -lt 24 ]
do
	while [ $MIN -lt 60 ]
	do
		while [ $SEC -lt 60 ]
		do 
			$TIMELOC
			echo -n "Time: $HOUR:$MIN:$SEC   "   
			$CURLOC
			sleep 5
			SEC=`expr $SEC + 5`
		done
		SEC=0
		MIN=`expr $MIN + 1`
	done
	MIN=0
	HOUR=`expr $HOUR + 1`
done
echo

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ uunet!iex!neptune!danny   ~  IEX CORPORATION-      ~
~ Whats in a sig. anyway?   ~  1400 Preston rd. #350 ~
~                           ~  Plano, TX. 75093      ~
~i'd rather be water skiing ~  (214) 612-2600        ~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



More information about the Alt.sources mailing list