The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Creating a menu yoavbe Shell Programming and Scripting 4 02-08-2008 08:18 AM
Creating a menu from find markrj Shell Programming and Scripting 3 01-22-2008 09:50 AM
Creating a menu within a script file sinjin Shell Programming and Scripting 8 12-09-2007 10:18 PM
creating a file with a list hinman UNIX for Dummies Questions & Answers 5 02-06-2007 01:25 PM
Creating User Accounts from a list in file Laila Saif Shell Programming and Scripting 8 12-21-2005 08:23 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 01-10-2006
Registered User
 

Join Date: Jun 2004
Posts: 146
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
Reply With Quote
Forum Sponsor
  #2  
Old 01-10-2006
Technorati Master
 

Join Date: Mar 2005
Location: Large scale systems...
Posts: 2,610
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 04:07 AM.
Reply With Quote
  #3  
Old 01-10-2006
Registered User
 

Join Date: Jun 2004
Posts: 146
Thanks but it does not work

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
Reply With Quote
  #4  
Old 01-10-2006
Technorati Master
 

Join Date: Mar 2005
Location: Large scale systems...
Posts: 2,610
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.
Reply With Quote
  #5  
Old 01-10-2006
Registered User
 

Join Date: Jun 2004
Posts: 146
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.
Reply With Quote
  #6  
Old 01-10-2006
linuxpenguin's Avatar
Registered User
 

Join Date: May 2002
Location: India
Posts: 295
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.
__________________
War doesnt determine who is right, it determines who is left
Reply With Quote
  #7  
Old 01-10-2006
zazzybob's Avatar
Registered Geek
 

Join Date: Dec 2003
Location: Melbourne, Australia
Posts: 2,100
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
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 05:57 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0