Sponsored Content
Full Discussion: Shell script menu problem
Top Forums Shell Programming and Scripting Shell script menu problem Post 302598814 by goddevil on Wednesday 15th of February 2012 01:23:56 PM
Old 02-15-2012
Shell script menu problem

I have tried searching the forum but i haven't found a solution for this.

I have a shell script that presents the users with menus. The menus branch out to sub menus. It is all hunky dory as long as i traverse forward. But if i am in a sub menu and return to the previous menu and choose any option, i am taken back to the sub menu. I can see where i am going wrong in my code as you can see highlighted below. But i cannot get around it unless i return to the main menu which has become quite cumbersome. Is there any way i can get around this by using goto labels? Any other modification of my code to get around this issue will be appreciated as well. Thanks in advance
Code:
 
function mainmenu {
echo "--------------- MAIN MENU -------------------"
echo " 1. CH1 "
echo " 2. CH2 "
echo " 3. CH3 "
echo "Choose 1-3"
read choice
case $choice in
1)
    while :
    do
    submenu # calling another menu here
    case $subchoice in
        1)
               do something
               ;;
        2) 
              do something
              ;;
        3)
              do something
              ;;
        4)
              do something
             ;;
        5)
             mainmenu
             ;;
        6)
             uexit                    #  calling the function to exit
             exit 1 
             ;;
        esac
       done
       ;;
2)
     while :
     do
               submenu2 # calling another menu here
            case $subchoice2 in
            1)
                   do something
                   ;;
           2)
                  do something
                  ;;
           3)
                 while :
                 do
                                submenu3 # calling another menu here
                         case $subchoice3 in
                         1)
                                  do something
                                  ;;
                        2)
                                 do something
                                 ;;
                       3)
                                do something
                                ;;
                      4)
                               do something
                               ;;
                      5)
                                      submenu2
                              ;;
                     6)
                              uexit
                              exit 1 
                             ;;
                     esac
                    done
                    ;;
          4)
                    do something
                     ;;
          5) 
                    mainmenu
                     ;;
          6)
                     uexit
                    exit 1  
                     ;;
          esac
        done 
       ;;
3)
      do something
       ;;
4)
      uexit
      exit 1
    ;;
esac
return
}
mainmenu


Last edited by goddevil; 02-15-2012 at 03:28 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Unix Shell Script: With Menu Option

I am attempting to create a shell script with the following capaciblities: 1. Listed options to choice from 2. Use to perform awk statements 3. Print a report with the awk results My questions are 1. How do I select more than one file for option #5 and #6 2. How to I create an... (11 Replies)
Discussion started by: jroberson
11 Replies

2. Shell Programming and Scripting

Script menu problem

Hi there, I am new to Unix and at the moment I am trying to solve my assignment that is to create a script for the program to prompt user to type three codes, from user point of view it should be done by typing codes separating them by spaces. Then program displays a menu with these three... (2 Replies)
Discussion started by: Dannel
2 Replies

3. Shell Programming and Scripting

Shell script menu

hi guys, how would you do the following? I have a menu with 5 options in my shell script: 1. Run function 1 against files 2. Run function 2 against files 3. Run function 3 against files 4. Run function 4 against files 5. Run function 5 against files I'd like to be able to run multiple... (10 Replies)
Discussion started by: rich@ardz
10 Replies

4. UNIX for Dummies Questions & Answers

Menu Script problem

Im new to unix/linux and am having trouble with this one. My problem is when i enter 9 to exit it doesnt do so. also option 6 doesent display the time. Its getting to be frustrating. I know there are probably alot of bug in this bu these basic ones are really odd. #!bin/bash # until ... (3 Replies)
Discussion started by: christ.666
3 Replies

5. Shell Programming and Scripting

Menu using shell script

Hi, I need to have a shell script for the below need. 1. Menu with one heading and 4 options. 2. the heading and 4 options are taken from a file. File entry ====== Heading1|option1|option2|option3|option4| Heading2|option1|option2|option3|option4| 3. the user entries must be captured in... (9 Replies)
Discussion started by: umastinu
9 Replies

6. Shell Programming and Scripting

Execution Problem with dispalying file content using menu driven script

HI All.. below is my menu options script. in option 2,3 and 4 im giving input and they are saving into their respective text file. problem is when im trying to "cat" those files in options 7,8 and 9 im not getting the output. no respective file contents are displaying on screen. but if i... (1 Reply)
Discussion started by: saichand1985
1 Replies

7. Shell Programming and Scripting

A selection menu in a shell script

I'm writing a shell script and have a problem with selection when I issue the command, is there a way to automatically choose a selection number one after a selection menue appear Command 1-choice 2- choice 3-choice Thanks Sara (3 Replies)
Discussion started by: Sara_84
3 Replies

8. Shell Programming and Scripting

Menu shell script help

Hi All, I have written a shell script that show menu driven option. My requirement is that in the menu driven option i want to select multiple choice. i.e if i want to select 1 or 1,2 or 1,2,3 or 2,3 etc .... Can some one help me in that My script. while true; do echo " " ... (8 Replies)
Discussion started by: Nawrajesh
8 Replies

9. Shell Programming and Scripting

Automate the menu options using shell script

I have a menu option which will look as follows Select a menu option 1.change password 2.login as root user 3.show system version 4.quit Select> 1 please enter the new password: unix reenter the new password: unix press any key to enter (then displays again the menu options to enter the... (4 Replies)
Discussion started by: shivakumar6g
4 Replies

10. Shell Programming and Scripting

How to include menu based options in Shell script?

Hi Friends, I have a menu based tool which requires input/option to proceed further. How to make a shell script ? eg: menu looks like Get_data.sh to continue (y/n) : Here I need to key in "y" to proceed. I want to prepare a script which should consider option y. (5 Replies)
Discussion started by: suresh3566
5 Replies
install-menu(1) 					      Debian GNU/Linux manual						   install-menu(1)

NAME
install-menu - Process a menu method and generate the menu files for a window manager or a menu-aware application. DESCRIPTION
update-menus(1) computes the list of menu entries and passes it in turn to the menu methods in /etc/menu-methods/. The task of a menu meth- ods is to generate menus for a specific window manager. install-menu provides a generic and customizable way to do that. The documentation of the install-menu definition language is available in the Debian Menu manual, a local copy being available in /usr/share/doc/menu/html. SYNOPSIS
install-menu [-vh] [--remove] <menu-method> Read menu entries from stdin in update-menus --stdout format and generate menu files using the specified menu-method. Normally used in menu method scripts as #! /usr/bin/install-menu. OPTIONS
-h,--help Show the help message and exit. --remove Remove the menu files instead of generating them. -v,--verbose Output messages about what the program is doing. COPYING
install-menu is distributed under the term of the GNU General Public License version 2, or (at your option) any later version. AUTHOR
Written by Joost Witteveen <joostje@debian.org>. Now maintained by Bill Allombert <ballombe@debian.org>. SEE ALSO
update-menus(1), menufile(5), /usr/share/doc/menu/html Debian Project 28 November 2005 install-menu(1)
All times are GMT -4. The time now is 07:29 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy