ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Welcome to LinuxQuestions.org, a friendly and active Linux Community.

You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!

Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.

If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.

Having a problem logging in? Please visit this page to clear all LQ-related cookies.

Introduction to Linux - A Hands on Guide

This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.

another minor problem with select, and one i cant seem to find an answer for.

i have a little menu bash script, that i have listed below, thats using subroutines to generate some menu's. it actually works very well, with one minor problem, when the dmenu subroutine returns to the mainmenu subroutine, all i have displayed is the #? prompt, it doesnt show the mainmenu menu choices. is there a way to "force" select to re-display its menu?

ive given an example of the output below the script, i think the example explains whats happenning better than i can with words.

wht i am trying to do, is have the main menu text shown where i have indicated, but i cant seem to work out how to "force" select to display its menu.

does anyone know how i can make select show its menu text when the submenu subroutine returns? ive been fiddling with this all day yesterday, and most of the morning, and i just cant seem to figure it out.

i had considered putting the mainmenu command in there, but surely that would mean the script has multiple subroutines to back out of, with each one needing a "go back" command?

like: mainmenu -> submenu -> mainmenu -> submenu
with each of the routines needing the user to select the relevant "go back" option?

i guess the exit on the mainmenu routine would allow the user to break out of the chain without having to back up, but im a little concerned at having them stacked like that. it seems..... 'messy' (for want of a better word)

I think im going to be using the case matching thing. as you can no doubt tell, im a relative noob when it comes to shell scripts, but i think im getting the hang of it now. the case thing looks like what i was origonally looking for before i just used if.

on the whole, ive a feeling that it might just be easier to write my own menu system, rather than using select. i think im quickly discovering limitations in select that are going to make my life hard, when i can just create some menu functions and have it work perfectly.

i think the while and case are the way to go, tbh im not sure select is what i need for this, for all the time its taken me to figure out how to bend it to my will, i could have just written a menu from scratch. whilst select is usefull for "quick and dirty" menu selections, i think something like this is gonna need me to get my hands dirty and make it myself.

so far im working on the theory of:

while var is true, do

display menu

read

case for answers

wend.

or similar, it seems a pretty solid way to go with it. much like your example, only with a man-made menu instead of select.

thanks for all the help guys, it seems like select is just not what i was looking for on this one, but it was good to see the different ways of using it that you suggested looks like its back to the drawing board on this one, but as they say, all experience is good experience.