Databases
cancel
Showing results for 
Search instead for 
Did you mean: 

Problems when creating a set of menus via shell scripts

SOLVED
Go to solution
Keith Fuller_1
Occasional Contributor

Problems when creating a set of menus via shell scripts

Hi All

I am new to shell scripting and am trying to create a set of menus from scratch. I have created the menus and linked them together, but when i type quit i get sent back to the previous menu instead of returning to the command line. is there anyway of getting the menus to exit straight to the command line, rather then having to type quit for each copy of the menu i have visited.
Thanks in advance for the help
7 REPLIES
Paula J Frazer-Campbell
Honored Contributor

Re: Problems when creating a set of menus via shell scripts

Hi Keith

This might help:-

continue="yes"
while [ "$continue" = "yes" ]
do
clear

echo "--------------------------------- "
echo " MAIN MENU "
echo " -------------------------------- "
echo "| |"
echo "| 1 : SYSTEM CHECKS |"
echo "| 2 : SPIDERS |"
echo "| 3 : SAM |"
echo "| 4 : System Control |"
echo "| 5 : UV Admin |"
echo "| 6 : Misc Checks |"
echo "| 7 : Predictive |"
echo "| 8 : S.T.M. |"
echo "| 99 : Make Recovery |"
echo "| x : Exit Menu |"
echo " -------------------------------- "
echo "| PJFC 02/2000 |"
echo " -------------------------------- "
# updated for new sys checks
read ans
case $ans in
1) ./sysadmin/menu/syschk
;;
11) telnet 191.1.0.103
;;
111) telnet 191.1.0.105
;;
2) ./sysadmin/menu/spider
;;
3) sam
;;
4) ./sysadmin/menu/control
;;
5) cd /universe/uv
uv
;;
6) ./sysadmin/menu/checks
;;
7) ./opt/pred/bin/psconfig
;;
8) ./usr/sbin/stm/ui/bin/stm
;;
99) ./opt/ignite/bin/make_tape_recovery -x inc_entire=vg00 -I -v -a /dev/rmt/1mn
;;
x) continue="no"
;;
X) continue="no"
;;
esac
done



Paula
If you can spell SysAdmin then you is one - anon
Paula J Frazer-Campbell
Honored Contributor
Solution

Re: Problems when creating a set of menus via shell scripts

Hi Keith

If you exec your sub menu then an exit from that will not take you back to the previous menu.

I.E.

exec /sysadmin/submenu


HTH

Paula
If you can spell SysAdmin then you is one - anon
harry d brown jr
Honored Contributor

Re: Problems when creating a set of menus via shell scripts

NO BIGGIE:

Change these lines where you call another menu:

testment:
1) echo "Day Tasks"
sleep 2
daytasks
;;

to
exec daytasks

daytasks:
4) echo "Back to main menu"
sleep 1
testmenu
;;

to

exec testmenu


Although crappy coding IMO, its the solution you are looking for.

live free or die
harry
Live Free or Die
Steve Steel
Honored Contributor

Re: Problems when creating a set of menus via shell scripts

Hi


FYI http://www.introcomp.co.uk/examples/index.html

contains some good examples


Solutions.

After you call a new menu in a script put the word exit on the next line so the menu will
return to the previous menu and autoexit

ro

Use
. menu

To activate menus.This stops the shell forking and continues at the same shell level.


Steve Steel
If you want truly to understand something, try to change it. (Kurt Lewin)
James R. Ferguson
Acclaimed Contributor

Re: Problems when creating a set of menus via shell scripts

Hi Keith:

If you divide your submenus into functions, you can use the 'return' command to exit the function (submenu) and thereby return to the "outer block" (main menu). If you wish to abandon processing within a function without further ado, use 'exit' in lieu of the 'return' statement.

Have a look at the 'sh_posix' man pages. A quick overview of shell commands can be found here ("Shells: User's Guide"):

http://docs.hp.com/hpux/onlinedocs/B2355-90046/B2355-90046.html

Regards!

...JRF...
Keith Fuller_1
Occasional Contributor

Re: Problems when creating a set of menus via shell scripts

Hi everyone

Thanks for all your help, this now works.

Regards

Keith Fuller
Thanks in advance for the help
MAD_2
Super Advisor

Re: Problems when creating a set of menus via shell scripts

Sorry guys for not posting what may appear to be enough points. However, I have seen at least one menu driven application written in ksh that allowed the user to navigate through the options by means of the arrow keys. For my initial menu options I am using numbers/letters.

Thanks a lot for the responses so far. If/when I come up with a solution, I'd like to post the script, if I complete it :-) Well, at least the parts that are breaking my brain at the moment.

Thanks!

Adam.
Contrary to popular belief, Unix is user friendly. It's just very particular about who it makes friends with