Creating menu list from configuration file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Creating menu list from configuration file
# 1  
Old 01-10-2006
Creating menu list from configuration file

Hi folks,

I have the following function ,which generates menu for installation type:
Code:
select_install_type()
{

        echo
        echo ========================================
        echo Please select the type of installation:
        echo ========================================
        echo

        pass=fail
        until [[ ${pass} = pass ]] ; do

        select installType in `cat /tmp/layers.conf`
                do
if [[  ${installType} = "Quit" ]] ; then

                        echo "\n**** !! Exiting by user's request !! ****\n"
                        exit 2

                elif  [[ -z "${installType}" ]] ; then

                        echo "\n**** !! Invalid Option !! ****\n"
                        continue
               elif [[  ${installType} = "Database_Layer"  ]] ; then
                        export installType=DatabaseLayer
                        pass=pass
                        break
elif [[  ${installType} = "RiGHTv_Admin_Layer"  ]] ; then
                        export installType=RTEAdminLayer
                        pass=pass
                        break

                elif [[  ${installType} = "RTEsub_Layer"  ]] ; then
                        export installType=RTESubLayer
                        pass=pass
                        break

                else

                        echo "Invalid Install Type"
                        exit
                fi

        done
      done
}

The content of conf file layers.conf is:
Code:
root# cat layers.conf
Database Layer
RiGHTv Adminstration Layer
RTE Subscribers Layer
Quit

If I run it:
Code:
root# ./get_layer.ksh

========================================
Please select the type of installation:
========================================

1) Database
2) Layer
3) RiGHTv
4) Adminstration
5) Layer
6) RTE
7) Subscribers
8) Layer
9) Quit
#?

As you can see ,The problem is the spaces between the words which cause the menu to display each word in different line.
How can I overcome it?
The expected result is:
Code:
========================================
Please select the type of installation:
========================================

1) Database Layer
2) RiGHTv Adminstration Layer
3) RTE Subscribers Layer
4) Quit
#?

Thanks in advance,
Nir
# 2  
Old 01-10-2006
one idea i could suggest is have delimiters like "|" instead of spaces in your configuration file so that it look like

Database|Layer
Database_Layer


though this idea is not efficient this would solve your problem for sure.

Last edited by matrixmadhan; 01-10-2006 at 07:07 AM..
# 3  
Old 01-10-2006
Thanks but it does not work Smilie

Code:
========================================
Please select the type of installation:
========================================

1) Database|Layer
2) RiGHTv|Adminstration|Layer
3) RTE|Subscribers|Layer
4) Quit
#? 4

Any more suggestions?

Thanks in advance,
Nir
# 4  
Old 01-10-2006
I could see a mismatch in your configuration file and the hard-coded values in script,

Quote:
========================================
Please select the type of installation:
========================================

1) Database_Layer
2) RiGHTv_Adminstration_Layer
3) RTE_Subscribers_Layer
4) Quit
Have you changed the validation accordingly in the script ?

elif [[ ${installType} = "Database_Layer" ]] ; then

the underscore between Database and Layer !!!
hope this helps.
# 5  
Old 01-10-2006
Yes I saw this mismatch but it is does not influence about how the menu is displayed. It is still displayed incorrectly on the screen.
# 6  
Old 01-10-2006
hmm, i had always faced this problem with for loop, so i used to use a while loop

cat filename|while read a
do
..
done

but in this scenario, you may have to implement your own type of select, i.e ability to link these lines with line numbers.
# 7  
Old 01-10-2006
Quote:
Originally Posted by linuxpenguin
hmm, i had always faced this problem with for loop, so i used to use a while loop
cat filename|while read a
do
..
done
UUoC

while read line; do
.
.
done < filename
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Creating bash script to process a data file based on the menu

Hey, im fairly new to unix and Im trying to make this unix project that would display a menu and do the following. MENU =========================== (p, P) Print users info (a, A) Add new user (s, S) Search user (d, D) Delete user (x,X) Exit Enter your choice: Trying to... (3 Replies)
Discussion started by: ultimaxtrd
3 Replies

2. Shell Programming and Scripting

Need help creating a menu.

Hi Master of masters, Thanks for ur reply. Need ur help for following. Is it possible to create menu for following in linux or a function. > Look in logs > Status > Action > End Action > CONFSUCCESS > Success > Show message as successful > Enter to continue > CONFFAIL > Failure > Show... (1 Reply)
Discussion started by: rajeshwebspere
1 Replies

3. Shell Programming and Scripting

ls > file - Creating file containing the list of all files present in a directory

Hi All, I need to create a file which contains the list of all the files present in that directory. e.g., ls /export/home/user/*.dat > list_file.dat but what i am getting is: $ ls /export/home/user/*.dat > list_file.dat /export/home/user/*.dat: No such file or directory But I have... (1 Reply)
Discussion started by: pranavagarwal
1 Replies

4. Shell Programming and Scripting

Creating a menu

Hi, I need your help co create a very small menu somthing that look like this: 1. first step 2. second step 3. last step from step : ___ to step : ___ If the user choose 1 --> it will echo : Hellow If the user choose 2 --> it will echo : World If the user choose 3 --> it will echo... (4 Replies)
Discussion started by: yoavbe
4 Replies

5. Shell Programming and Scripting

Creating a menu from find

Hi I am wanting to create a menu that will list all the log files in a specific directory such as /apps/logs. So it would be something like this: #!/bin/ksh print 'Select The Required Log File' PS3='log? ' select choice in <this is to contain a list of files that are in a directory that... (3 Replies)
Discussion started by: markrj
3 Replies

6. Shell Programming and Scripting

Creating a menu within a script file

I am very new to Unix and know the basic commands. I have to write a script file and I'm completely lost. The script file is to show the following at the beginning: Menu of Options 1. Display all files in a user's home directory. 2. Welcome yourself to the program. 3. Display System... (8 Replies)
Discussion started by: sinjin
8 Replies

7. UNIX for Dummies Questions & Answers

creating a file with a list

I would like to create a text file that contains the list (names of files and dirs) of a particular directory... any ideas ? (5 Replies)
Discussion started by: hinman
5 Replies

8. Shell Programming and Scripting

Creating User Accounts from a list in file

I have a file that contains a list of names. I need a loop that creates user accounts to all the names in the list where username = names in file password = username Another question: how can i validate that a particular var is of 6 characters length I need an if statement that will... (8 Replies)
Discussion started by: Laila Saif
8 Replies

9. Shell Programming and Scripting

creating a menu for recycling and permanently deleting files.

Trying to alias rm to move files to a hidden trash directory in the bash shell. I've tried to create this alias numberous ways and it's just not working. Here's what I've tried, anyone have any suggestions. alias rm='mv $* ~/.trash' alias rm= 'mv$* ~/.trash' things like that... I've also... (2 Replies)
Discussion started by: strmy_ngts
2 Replies
Login or Register to Ask a Question