shell菜单
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
#Program: mmenu - shell script of user menu items
#Description:
# Program consisting of a series of functions providing user menus
# for simple tasks.
#
# Functions are loaded into memory and available for execution. Once
# loaded, the main menu will be invoked. The main menu (entry point) is :MainMenu. #
# The following functions are declared:
# MainMenu
# EditFile
# MailMenu
# UserUtilMenu
# FileDirUtilMenu
# GetFileName
# ExecuteCommand
#
# Last updated on 10/10/2002 by A.M. Foster
#************************************************************8
#Screen Display Variables
REV=`tput rev`
OREV=`tput sgr0`
BLD=`tput smso`
OBLD=`tput rmso`
#Various variables
MenuMsg=""
MenuChoice=""
#*********************************************************************8
#Routine: MainMenu
#Main Menu function which displays the main menu to stdout.
MainMenu()
{
#Menu loop
while true
do
tput clear
MenuChoice=""
#Main Menu - display the main menu
echo ""
echo ""
echo " ${REV}Main Menu${OREV}"
echo ""
echo ""
echo " 1. ${BLD}E${OBLD}dit / File "
echo ""
echo " 2. ${BLD}S${OBLD}end/Receive Mail ..."
echo ""
echo " 3. ${BLD}U${OBLD}ser Utilities ..."
echo ""
echo " 4. ${BLD}F${OBLD}ile Directory Utilities ..." echo ""
echo " 0. ${BLD}L${OBLD}og Off System"
echo ""
echo ""
echo "${BLD}${MenuMsg}${OBLD}"
echo ""
echo ""
echo -n "${BLD}Select: ${OBLD}"
MenuMsg=""
#Get user's choice and evaluate with case statement
read MenuChoice #get user selection
case ${MenuChoice} in
"1" | "e" | "E" )
EditFile
;;
"2" | "s" | "S" )
MailMenu
;;
"3" | "u" | "U" )
UserUtilMenu
;;
"4" | "f" | "F" )
FileDirUtilMenu
;;
"0" | "l" | "L" )
echo " "
echo " "
echo "Exiting per User request!"
sleep 2
tput clear
exit 1
;;
* )
MenuChoice=""
MenuMsg="${BLD}Invalid choice. Please try again.${OBLD}"
;;
#Example of menu command that is hidden from users. Note that
#it is not in the menu, but has a choice in the case statement.
"admin" )
ExecuteCommand 'ps -ef | more'
;;
esac #end of case statement
done #end of menu loop
}
#******************************************************************************* *****
#Routine EditFile
#Presents the Edit File Menu to stdout
EditFile()
{
MenuMsg=""
while true
do
MenuChoice=""
tput clear