ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
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.
Click Here to receive this Complete Guide absolutely free.
If I understand your question correctly, wrapping the select in an infinite loop may help:
# @(#) s1 Demonstrate re-display of menu.
PS3='DO YOU WISH TO LOAD THIS FILE? '
select opt in Yes No
case $opt in
echo runupd 20$days
echo after 20$days;;
No ) exit;;
* ) echo "Please select from an option number:"
Well what that does is not what exactly what I am looking for. I want:
DO YOU WISH TO LOAD THIS FILE?
After I select lets say 1 and the process for one is done. When I get back to the menu its displays as above not as below. Because when when I get the display as below I have to hit enter twice so the menu appears..
DO YOU WISH TO LOAD THIS FILE?
Is that understandable or do you need anything else for me to explain.
Yeah, i've done it a long time ago, but can't seem to find an example now.
Basically, assume a text style front end to a list of choices which do 'something'.
After a given choice completes, auto-redisplay the entire menu again.
On linux boxes this is correct behavior. The PS3 prompt and the LIST are only shown when the input is empty, otherwise only the PS3 prompt is shown.
I'll have to try and figure out why this differs on a none linux box (a SUN box in this case). SUN probably patched bash to change this behavior. I do believe that installing a 'normal' gnu bash on a SUN box will show the same behavior as on linux (LIST is only shown once).
Here's a different way to solve your problem:
echo 'DO YOU WISH TO LOAD THIS FILE? '
echo '1) Yes'
echo '2) No'
echo -n 'Please enter your choice : '
case $ANSWER in
"1" | "Yes" ) echo "Running programs."
"2" | "No" ) exit 0;;
* ) echo "Please select from an option above!"
Most assuredly this is not a timely answer but I had the same problem today and found a solution thanks to druuna's last post re: the menu is
not displayed unless the 'line read' value is null. Hopefully this provides a little time saver for someone else.
From the bash 'help select':
If the line is empty, WORDS and the prompt are
redisplayed. If EOF is read, the command completes. Any other
value read causes NAME to be set to null. The line read is saved
in the variable REPLY.
Pressing enter after the PS3 prompt is displayed nulls out the line read
and causes the menu to be redisplayed. The same effect is attained
by setting REPLY to null (REPLY='') at the bottom of the while loop.