Question
#================================================= Modify the given template by changing the function names, modifying menu to give choices that reflect the new names. and an action section that
#================================================= Modify the given template by changing the function names, modifying menu to give choices that reflect the new names. and an action section that calls the new functions by their new names. You must have at least 5 functions that can be called form the menu. Good indentation. Good comments. 5 UNIQUE FUNCTIONS Run your script file, choosing each option from the menu.
Upload a screen shot of the runs along with you your shell script. ====================================================================
Template of the program is given below:
do_choice_1() #empty function to be filled in by the scripter { : } do_choice_2() { : } do_choice_3() { : } do_choice_4() { : } do_choice_5() { : } Present_Menu() { #<< means read every line until the token: MENU, is #found then stop. The lines between the two #MENU tokens are called an internal document # cat << MENU 1. choice_1 #explanation 2. choice_2 # 3. choice_3 # 4. choice_4 # 5. choice_5 # q. (Q)uit # MENU echo "What would you like to do? " #For a menu, this is called a prompt #The script will then read the #user's response line by breaking #it up into white-space separated #fields and placing them in the six #variables: ACTION, PART1-5, if #there are #more than 6 fields, all fields #from 6 on are placed into variable #PART5, separated by single spaces #if there are less that 6 fields #the corresponding PART* variables #will be blank read ACTION PART1 PART2 PART3 PART4 PART5 } Evaluate_Action() { #set -xv #set -xv is a 'turn debug on' command, it is commented out #the case staments looks for several different possible #values for the variable:ACTION. And calls a function #above, based on whatever the user types in for an action case $ACTION in choice_1|1) #HERE: the pipeline character is not used that way #it is used to mean 'OR' so if $ACTION is 'choice_1' or #just '1', then the actions here up to the two semicolons #will be executed. echo "Doing Choice 1" do_choice_1 ;; choice_2|2) # echo "Doing Choice 2" do_choice_2 ;; choice_3|3) # echo "Doing Choice 3" do_choice_3 ;; choice_4|4) # echo "Doing Choice 4" do_choice_4 ;; choice_5|5) # echo "Doing Choice 5" do_choice_5 ;; [qQ]*) #[] pair means any character that matches any of the characters #between the brackets. The * means any other character can #come after the q. echo "Quitting" CONTINUE=0 #CONTINUE is a state variable that we defined #0 means we no longer wish to continue this script ;; *) #*: means any string, so this is the default case #if none of the other cases above were matched. #a scripter should always have a default case in any #case statement, just in case. echo "ACTION, :$ACTION:, is not allowed." ;; esac set +xv : } CONTINUE=1 while [ $CONTINUE -eq 1 ] #while says while the CONTINUE state variable #is equal to 1, do the commands between the do #and the done lines do Present_Menu #call the Presnet menu Evaluate_Action $PART1 $PART2 $PART3 $PART4 $PART5 #Call the Evaluate_Action #with the variables as #arguments done
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started