The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


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 !!

More UNIX and Linux Forum Topics You Might Find Helpful
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

Closed Thread
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-12-2002
Registered User
 

Join Date: Dec 2001
Location: UK, England
Posts: 45
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
  #2 (permalink)  
Old 01-12-2002
Registered User
 

Join Date: Nov 2001
Posts: 60
In general you can use

tput clear

to clear the screen. Once the screen is clear, display you sub-menu.
  #3 (permalink)  
Old 01-13-2002
Registered User
 

Join Date: Dec 2001
Location: UK, England
Posts: 45
I know how to do a standard clear, but not sure how to do a enter/add the sub menu part of the display in my existing script.

Can you give me an example of a menu which displays sub menu's??
  #4 (permalink)  
Old 01-13-2002
merlin
Guest
 

Posts: n/a
Well depending on how you are doing it all. I created one awhile back and well I used case statements. If you do it that way just add a statement inside the other statement!
  #5 (permalink)  
Old 01-13-2002
Jimbo
Guest
 

Posts: n/a
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
  #6 (permalink)  
Old 01-13-2002
Registered User
 

Join Date: Dec 2001
Location: UK, England
Posts: 45
Quote:
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

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).
  #7 (permalink)  
Old 01-14-2002
Registered User
 

Join Date: Dec 2001
Location: UK, England
Posts: 45
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?? I tried a few things but I just kept getting error messages. Can u help? (See my script in the previous post)
Google UNIX.COM
Closed Thread

Thread Tools
Display Modes




All times are GMT -7. The time now is 05:45 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 Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0