ksh: Need to read variables into variables

ksh: Need to read variables into variables

Post by Andree Fonteno » Thu, 14 Mar 1996 04:00:00



Inside a utility shell I have the statement:

  read TPL_LOC?" > " # get template path from user

I want to enter

 > $TPL_HOME/admin

where $TPL_HOME is a standard system variable and have $TPL_LOC
interpreted the same way it is on my command line.

The line

  TPL_LOC="$TPL_HOME/admin"

works, but I do not have the luxury of being able to hard code this. The
users of the utility need to enter their own pathnames.

Anyone have any ideas?

--
Andree Fontenot

"It isn't necessary to change; survival is not mandatory." - W. Edwards
Deming

 
 
 

ksh: Need to read variables into variables

Post by Bill Marc » Thu, 14 Mar 1996 04:00:00




Quote:>I want to enter
> > $TPL_HOME/admin
>where $TPL_HOME is a standard system variable and have $TPL_LOC
>interpreted the same way it is on my command line.
>Anyone have any ideas?

read TPL_X?"> "
eval TPL_LOC=$TPL_X

--

"They're all lawyers, and think that the laws of physics can be amended with


 
 
 

ksh: Need to read variables into variables

Post by Andree Fonteno » Fri, 15 Mar 1996 04:00:00



> read TPL_X?"> "
> eval TPL_LOC=$TPL_X

> --

> "They're all lawyers, and think that the laws of physics can be amended with


It works! Many, many, many thanks!

--
Andree Fontenot

"It isn't necessary to change; survival is not mandatory." - W. Edwards
Deming

 
 
 

ksh: Need to read variables into variables

Post by Brian Duan » Fri, 15 Mar 1996 04:00:00



> Inside a utility shell I have the statement:

>   read TPL_LOC?" > " # get template path from user

> I want to enter

>  > $TPL_HOME/admin

> where $TPL_HOME is a standard system variable and have $TPL_LOC
> interpreted the same way it is on my command line.

> The line

>   TPL_LOC="$TPL_HOME/admin"

> works, but I do not have the luxury of being able to hard code this. The
> users of the utility need to enter their own pathnames.

> Anyone have any ideas?

> --
> Andree Fontenot

> "It isn't necessary to change; survival is not mandatory." - W. Edwards
> Deming

Try using the "eval" statement e.g.

read TPL_LOC?" > " # get template path from user
eval ls $TPL_LOC

--
Brian Duane - NCR Corporation
(Formerly AT&T GIS, formerly NCR)

 
 
 

1. Using a variable in a variable name in KSH

Group,

  I want to be able to use a variable name in another variable name.
 So for a simple file like:
 file: Prod
        Devl
        Test
        User

  Then I want.

   for n in `<file`
     do
            $n_Mail=`grep $n some_file` ## To get a list of names...
    done

     echo  "Mail var is $n_Mail : (and contents..??) "

    Output being.

     Prod_Mail :  joe jim etc
     Devl_Mail  : fred sally ...
     Test_Mail  :  etc
     User_Mail  :  etc

     So how can I assign the variable using the $n variable and view
the name  of the variable asn well as the contents..

  Any help greatly appreciated.

  Robert Gease

2. Anyone tried adding a second pair of IDE controllers

3. Setting variables in a variable array of null variables

4. X on WinBook XLi

5. Reading HTTP POST Variables in Shell Variables - HOW?

6. I can only log in as root

7. Needed: a variable who's name is controlled by a variable

8. Excess ARP requests

9. ksh: set variable by reading file

10. reading variables in text files with ksh

11. ksh unset read only variable (typeset -r)

12. ksh Help reading path variable from file

13. Need help with variables and KSH.