#!/bin/ksh # Menu_DRM.ksh by Daniel R. Martin Wed Oct 2 08:38:28 MDT 2002 # Template for a ksh shell script menu ######################## ### DEFINE FUNCTIONS ### ######################## function _choices { clear cat <= 500 7 ID Search PATH for $LOGNAME 8 Currently Mounted devices 9 HD Usage and mount-points 0 Exit BOX } # EOF _choices() function _action { ans='' while [[ -z "${ans}" ]] do echo -e "Which? \c" read ans done echo } # EOF _action() function _complog { # Required argument: $1 = output of logname command if [[ "${1}" != "${LOGNAME}" ]] then echo "Your Login ID is: \"${1}\" (real) and \"${LOGNAME}\" (su)." else echo "Your Login ID is: \"${1}\"." fi } # EOF _complog function _waiter { echo -e "\nPress to continue: \c" read waiting4u } # EOF _waiter() ############################# ### END DEFINE FUNCTIONS ### ### - BEGIN ACTUAL MENU - ### ############################# moi=`logname` # doing outside of loop saves resources. while true # do forever... do _choices # display the menu _action # gather user response case "${ans}" in # process response 1) echo -e "The current directory is: \c"; pwd; _waiter ;; 2) _complog "${moi}"; _waiter ;; 3) ps -ef | grep "${moi}" | more ; _waiter ;; 4) grep "${moi}" /etc/passwd; _waiter ;; 5) awk -F":" '$3 == 0 {print $0}' /etc/passwd; _waiter;; 6) awk -F":" '$3 >= 500 {print $0}' /etc/passwd | more ; _waiter;; # 7) echo $PATH; _waiter ;; 7) echo $PATH | awk 'BEGIN {RS=":"}; {print $0}'; _waiter;; # 8) mount; _waiter;; 8) mount | awk '$1 != "none" {print $0}'; _waiter;; 9) df; _waiter ;; 0) clear; exit 0 ;; # breaks the loop *) echo "Unknown option \"${ans}\"!" ; _waiter ;; # handle exceptions esac done # EOF Menu_DRM.ksh