Article Title: A good idea menu. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
Code:
# 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
# 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
# Routine EditFile
# Presents the Edit File Menu to stdout
EditFile ()
{
MenuMsg = ""
While true
Do
MenuChoice = ""
Tput clear
Echo ""
Echo ""
Echo "$ {REV} edit file $ {OREV }"
Echo ""
Echo ""
Echo "1. $ {BLD} E $ {OBLD} nter File Name"
Echo ""
Echo "2. Enter File Name from Li $ {BLD} s $ {OBLD} t ..."
Echo ""
Echo "0. $ {BLD} M $ {OBLD} ain Menu"
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 ")
Echo-n "Enter file name to edit :"
Read FileName
If [-z "$ {FileName}"] # check if user provided a file name
Then
MenuMsg = "You did not enter a valid file name! "
Else
If [-f $ {FileName}] # check if file exists
Then
# Check if file is a text file
If ["file $ {FileName} | grep text>/dev/null"]
Then
Filesoktoedit = "y"
Else
MenuMsg = "$ {FileName}-is not an editable file! "
Fi
Else
Filesoktoedit = "y"
Fi
Fi
If [$} filesoktoedit} = "y"]
Then
Vi "$ {FileName }"
Echo ""
Echo "Press any key to continue .."
Fi
;;
If [$? -Eq 0]
Then
If ["file $ {FileName} | grep text>/dev/null"]
Then
Vi "$ {FileName }"
Echo ""
Echo "Press any key to continue .."
Else
MenuMsg = "$ {BLD }$ {FileName}-is not an editable file! $ {OBLD} 1"
Fi
Fi
;;
"0" | "m" | "M ")
Break
;;
*)
MenuChoice = ""
MenuMsg = "$ {BLD} Invalid Choice! Please try again. $ {OBLD }"
;;
Esac
Done
Return 0
} # End of EditFile function
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service