![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Rules & FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Need help with script for menu | sinjin | Shell Programming and Scripting | 0 | 12-10-2007 11:27 AM |
| Phone menu | Dawg101 | Shell Programming and Scripting | 1 | 05-27-2007 10:12 AM |
| Menu | space | Shell Programming and Scripting | 5 | 03-02-2005 02:05 AM |
| CDE menu | gabim | AIX | 1 | 10-20-2003 03:17 AM |
| Menu script | Ypnos | Shell Programming and Scripting | 9 | 07-02-2003 01:25 PM |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Sub menu's
I have designed a script menu, but I would like to to create sub menus e.g. I have my normal menu, then have a few options, and I for example choose option 2 and I would like it to take me to a whole new page (well, clear the screen) then allow me to choose from 5/6 options, which are functional. Dunno if that is clear but, ill give u an example:
Usual menu appears with 6 options e.g. 1. File functions 2. Directory functions 3. - 4. - 5. - 6. - And say I choose option 1, I would like it to clear the screen and take me to a new sub-menu e.g. 1. Delete 2. Copy 3. Remove etc Is this possible?? Because I tried altering my current menu and basically cutting the whole menu and putting a copy of it under where I define the function, but it didnt work. Can ne1 help, or give pointers?? |
| Forum Sponsor | ||
|
|
|
|||
|
Here's a little example. The sub-menus are coded as procedures which are referenced by the main-menu code.
Code:
#!/bin/sh
file_menu() {
clear
echo '\n\n(File Functions menu processing goes here)'
sleep 2
}
dir_menu() {
clear
echo '\n\n(Directory Functions menu processing goes here)'
sleep 2
}
# Main Menu
while true
do
clear
cat<<endcat
1. File Functions
2. Directory Functions
9. Exit
endcat
echo 'Enter choice: \c'
read reply
case $reply in
1) file_menu;;
2) dir_menu;;
9) return;;
*) echo 'invalid choice'
sleep 2;;
esac
done
|
|
|||
|
Quote:
This is my menu script so far: !/bin/ksh amenu () { clear echo `date` echo echo "\t\t\tMy Personal Menu" echo echo "\t\tPlease Select:" echo echo "\t\t\t 1. Directory display" echo "\t\t\t 2. Current Activity" echo "\t\t\t 3. Who is logged on" echo "\t\t\t 4. File functions" echo "\t\t\t 5. Directory functions" echo "\t\t\t 0. Exit" echo Select by pressing a number and then ENTER ; } PressEnter () { echo Press Enter read x } DirectoryDisplay () { ls -l|more PressEnter } CurrentActivity () { ps -ef|more PressEnter } WhoIsLoggedOn () { who|more PressEnter } Filefuctions () { ????????????????????????????? PressEnter } Directoryfunctions () { ????????????????????????????? PressEnter } while true do amenu read answer case $answer in 1) DirectoryDisplay ;; 2) CurrentActivity ;; 3) WhoIsLoggedOn ;; 4) Filefunctions ;; 5) Directoryfunctions ;; 0) break ;; esac done clear ------ Can ne1 that can help cut and paste the changes that I need to make (please see the quote above for more information). |
|
|||
|
Thanx Jimbo, must have posted at the same time, coz I didnt see ur example at first, thanx for that. I tried it and it worked, but I rather use my existing script, how can I alter that so that it works??
|
|||
| Google UNIX.COM |