My menu function

Below is my menu options code. It allows user to pick one of two option. I can get the first option to work, because if it is selected it just "breaks" and carries on with the script.

What i want to know is if a user selects option two how do i get that option to ignore all the other script and go to another specific part to carry out other commands??? ( i have indicated the problem by putting ########)

while true; do
    echo " "        
    echo "Main Menu: "
    echo "Please Select An Option Using The Options Provided."
    echo " "        
    echo "1 - Search All Files"
    echo " "        
    echo "2 - Idex Page Information"
        echo " "
        echo "Q - Quit"
        echo " "
        echo "Please enter your option: "
        read CHOSEN_KEY
        case $CHOSEN_KEY in
                [1])    echo " "
            echo "You Have Selected To Search All Files For Hits"
                        break;;                               # By using break i carry on my script which works correctly.
                [2])    echo " "
            echo "You Have Selected To Access Index Page Information"
                      ######;;
                Q|q)    echo " "
            echo "Goodbye"
                        exit;;
        esac
done

What do you mean by "make my menu run"? What errors do you get? Do you have a problem starting it like

me@mybox$ mymenu.sh

Therefore you have to set proper rights, e.g. execute-bit (chmod 755 mymenu.sh). First line of your program must be "#!/bin/bash". If your current working dir is not in your $PATH (preferred) you must start via

me@mybox$ ./mymenu.sh
[2])    echo " "
			echo "You Have Selected To Access Index Page Information"
                       ###What do i put here to make it go to a new set of funtions###;;

Basically if i use this part of my script to move to another place for example the user selects option two, and i want it to output a function: so i type:

 [2])    echo " "
			echo "You Have Selected To Access Index Page Information"
                   readindex;;

###and have later in my code####

readindex () {

echo "hello"

}

it does not work

Well, might there be some difference (more specificly: a space) between the call to "readindex" and your function's name "read index"?

********************************************* Thread Closed ******************************************************

What problems are you having?

Your menu runs as is (after uncommenting the double semi-colons in the case statement; see below).

You do not need a shebang at the top of the file, but you should make the script executable. (You can run it without its being executable, by calling it as a argument to sh.)

When posting code, please format it so that it will fit into a typical screen. It is best to keep the number of characters per line below 80.

Don't write useless comments. It's obvious what those lines do.

What are ".hits files"? What do they contain? Does your search pattern match the format in the files?

You have commented out the ';;' so that the script will not run as is.

What "new set of functions" do you want to run? If it's in a separate script, just call that script; if not, you should probably use shell functions (which must be defined before they are called).

Why the pause?

You should make the script more user friendly by prompting for a date all in one go:

printf "%s " "Enter date in the format 'YEAR Month Day':"
read YEAR MONTH DAY

And put it and other parts of your script in their own shell functions to make the code easier to read and easier to test section by section:

getdate()
{
  printf "%s: " "Enter date in the format 'YEAR Month Day'"
  read YEAR MONTH DAY

  ## Supply functions check_year, check_month and check_date
  check_year || return 1
  check_month || return 1
  check_date || return 1
}

while true; do
  ## print menu
  printf "%s\n" "1. ..." "" "2. ..." "" "Q - Quit" ""
  printf "%s: " "Enter your choice"
  read option
  case $option in
    1) until getdate; do :; done
       ## do whatever
       ;;
    2) : ## do whatever
       ;;
    q|Q) exit
         ;; 
done

please see other post:

But in reply to your questions: .hits files are numerous files populated with hundres of rows in the format:

137.44.2.8 	Mon 		Feb 4 		22:02:35 GMT 2008
149.192.2.81 	Mon 		Feb 4 		23:22:12 GMT 2008
132.53.17.171 	Tue 		Feb 5 		01:56:16 GMT 2008

I have scripts that search sepearetly for the date month and year to output the results into a tempfile. Thus limiting the results from all the hits files.
I am using a grep command to do so.

Secondly I use the case command to validate all of these inputs the user makes.

The reason i have not grouped it all together, is because i dont know how. Unlike most "students" on here i tend to only use what i understand or know. compared to people who just post hwk on here, and if i need help with a command then i come to here. Although this has nothing to do with coursework, and is just a mess about task for me to help me with my placement for next year where i will be having unix and perl experience.

I am a complete beginner to this. The reason there are pauses is because its just so i can see if everything runs ok and it gives me time to look at it.

If you refer to the link above you will see the problem. I want my "option 2" in my menu to ignore the stuff i already have in place, and run something else in the same script.

Sorry to be such a lamen about this whole thing but its the first time ive extensively used UNIX.