The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM
Home Forums Register Rules & FAQ Members List Arcade Search Today's Posts Mark Forums Read


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. Shell Script Page.


Other UNIX.COM Threads You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Passing global variable to a function which is called by another function sars Shell Programming and Scripting 4 5 Days Ago 08:39 AM
My menu function [new code -revised] amatuer_lee_3 Shell Programming and Scripting 3 05-18-2008 04:05 AM
CDE menu gabim AIX 1 10-20-2003 03:17 AM
Sub menu's Makaveli.2003 UNIX for Dummies Questions & Answers 20 01-21-2002 06:15 AM
Menu function stuck in a loop? darthur UNIX for Dummies Questions & Answers 2 12-14-2001 12:16 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-17-2008
Registered User
 

Join Date: May 2008
Posts: 53
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
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 ########)

Code:
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

Last edited by amatuer_lee_3 : 05-17-2008 at 07:14 PM.
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 05-17-2008
Registered User
 

Join Date: Apr 2008
Location: European Union/Germany
Posts: 173
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
What do you mean by "make my menu run"? What errors do you get? Do you have a problem starting it like

Code:
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

Code:
me@mybox$ ./mymenu.sh
Reply With Quote
  #3 (permalink)  
Old 05-17-2008
Registered User
 

Join Date: May 2008
Posts: 53
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
Code:
[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:

Code:
 [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

Last edited by amatuer_lee_3 : 05-17-2008 at 06:40 PM.
Reply With Quote
  #4 (permalink)  
Old 05-17-2008
Registered User
 

Join Date: Apr 2008
Location: European Union/Germany
Posts: 173
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
Well, might there be some difference (more specificly: a space) between the call to "readindex" and your function's name "read index"?
Reply With Quote
  #5 (permalink)  
Old 05-17-2008
Registered User
 

Join Date: May 2008
Posts: 53
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
********************************************* Thread Closed ******************************************************

Last edited by amatuer_lee_3 : 05-17-2008 at 07:14 PM.
Reply With Quote
Google UNIX.COM
Reply



Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -7. The time now is 10:37 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger

Search Engine Optimization by vBSEO 3.1.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102