Getting error in this expression: value of value


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Getting error in this expression: value of value
# 1  
Old 03-12-2012
Data Getting error in this expression: value of value

HI ,

I have a variable "TYPE" which may contain different values.
and another variable $TYPE"_SOURCE"

I am using ${$TYPE"_SOURCE"} to get the value TYPE_SOURCE for eg.
TYPE=ABC
ABC_SOURCE=/abc/xyz

On using above command I am getting error : BAD SUBSTITUTION

eval is not installed on my server.

Kindly help.
# 2  
Old 03-12-2012
Quote:
eval is not installed on my server
The eval command is normally a shell built-in.
What Operating System and version do you have and what Shell are you using?

Code:
# The eval method
TYPE=ABC
ABC_SOURCE=/abc/xyz
eval FRED=\$${TYPE}_SOURCE
echo $FRED

./scriptname
/abc/xyz

These 2 Users Gave Thanks to methyl For This Post:
# 3  
Old 03-13-2012
Thank you methyl.

This one worked for me : eval ABC_SOURCE='$'${TYPE}_SOURCE
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Observing error :syntax error in expression

#!/bin/bash a1="04:29:39 - System health check failed" i=$1 echo "a $((a$i))" The script above gives the following error $113> sh tryt.sh 1 tryt.sh: line 6: 04:29:39 - System health check failed: syntax error in expression (error token is ":29:39 - System health check failed") It... (1 Reply)
Discussion started by: ashima jain
1 Replies

2. UNIX for Advanced & Expert Users

sed: -e expression #1, char 0: no previous regular expression

Hello All, I'm trying to extract the lines between two consecutive elements of an array from a file. My array looks like: problem_arr=(PRS111 PRS213 PRS234) j=0 while } ] do k=`expr $j + 1` sed -n "/${problem_arr}/,/${problem_arr}/p" problemid.txt ---some operation goes... (11 Replies)
Discussion started by: InduInduIndu
11 Replies

3. Shell Programming and Scripting

if: expression syntax error in gawk

I'm pretty new to shell scripting, but I am catching on quick. I did see one of the stickied threads about the csh, and I think this is relevant, but I don't understand enough to make a decision based on it. So as you'll see below, I use the |csh pipe, and if that is not correct, I'm certainly... (2 Replies)
Discussion started by: macman104
2 Replies

4. Shell Programming and Scripting

Error: integer expression expected

root@server01 # df -h | grep /tmp | awk {'print $3}' 252M root@server01 # root@server01 # cat /usr/local/tmpchk.sh #!/bin/sh x=`df -h | grep /tmp | awk {'print $3}'` if ; then rm -fr /tmp/somefolder/ else echo "its small" (2 Replies)
Discussion started by: fed.linuxgossip
2 Replies

5. Shell Programming and Scripting

if expression syntax error

#! /bin/csh set umr=UMR foreach i ( `ls`) set file_nm=$i set bh_nm=`echo $file_nm | cut -d"_" -f2` if($bh_nm !=$umr) then { set bh_ext=`echo $file_nm | cut -d"_" -f4` set bh_num_nm="$bh_nm $bh_ext a .txt" mv $file_nm $bh_num_nm } ... (1 Reply)
Discussion started by: jdsignature88
1 Replies

6. Shell Programming and Scripting

Error with Expression

Hi All, am trying to add two Inputs i.e., $1 and $2, Code #!/bin/sh $num_sum=`expr $1+$2` echo "Sum = $num_sum" am giving statement sh arithemetic.sh 20 10 am getting error arithemetic.sh: line 2: =20+10: command not found Sum = I want Output as Sum = 30, (5 Replies)
Discussion started by: sunnix
5 Replies

7. Shell Programming and Scripting

One more expression syntax error

HI again, still working on the assignment, which is really hard given we just started unix 4 weeks ago. This script should change the permission for the user depending if its x, w or r, to the opposite. When i try to run it, I am getting expression error. Can you spot where the problem is? I really... (3 Replies)
Discussion started by: morava
3 Replies

8. Shell Programming and Scripting

integer expression expected error

I'm a beginner so I might make beginner mistakes. I want to count the "#define" directives in every .C file I get the following errors: ./lab1.sh: line 5: ndef: command not found ./lab1.sh: line 6: #!/bin/sh for x in *. do ndef = 'grep -c \#define $x' if ; then ... (2 Replies)
Discussion started by: dark_knight
2 Replies

9. UNIX for Advanced & Expert Users

Regular Expression Error in AWK

I have a file "fwcsales_filenames.txt" which has a list of file names that are supposed to be copied to another directory. In addition to that, I am trying to extract the date part and write to the log. I am getting the regular expression error when trying to strip the date part using the "ll"... (1 Reply)
Discussion started by: madhunk
1 Replies

10. Programming

error: initializer expression list treated as compound expression

I had seen this error for the first time ..... error: initializer expression list treated as compound expression please help.... (12 Replies)
Discussion started by: arunchaudhary19
12 Replies
Login or Register to Ask a Question