Gentoo Forums
Gentoo Forums
Quick Search: in
[solved] eval a shell variable
View unanswered posts
View posts from last 24 hours

rackathon
 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
toralf
Veteran
Veteran


Joined: 01 Feb 2004
Posts: 1139
Location: Hamburg/Germany

PostPosted: Thu Jan 31, 2008 5:36 am    Post subject: [solved] eval a shell variable Reply with quote

I try something like this :
Code:
SQL_FOO="select * from foo"
SQL_BAR="select * from bar"

T="FOO"

RESULTS=`$SQL_$T`
Currently I get obviously not the result set from the DB.
My question is, how can I first create a variable name and after that use the _content_ the variable points to ?


Last edited by toralf on Sun Mar 16, 2008 3:19 pm; edited 1 time in total
Back to top
View user's profile Send private message
Voltago
Veteran
Veteran


Joined: 02 Sep 2003
Posts: 2237
Location: Hinter den Materiequellen

PostPosted: Thu Jan 31, 2008 6:15 am    Post subject: Reply with quote

Code:
myvar=hello
varname=myvar
echo $varname
echo ${!varname}


Oh, and btw:
http://www.tldp.org/LDP/abs/html/
Back to top
View user's profile Send private message
toralf
Veteran
Veteran


Joined: 01 Feb 2004
Posts: 1139
Location: Hamburg/Germany

PostPosted: Thu Jan 31, 2008 7:12 am    Post subject: Reply with quote

thanks,
unfortunately I have to code this within ksh under IX 5.3 :-(
But this works :
Code:
[tfoerste@detlmtst01] /home/tfoerste> SQL_FOO="select count(id) from adm.agent"
[tfoerste@detlmtst01] /home/tfoerste> T=SQL_FOO
[tfoerste@detlmtst01] /home/tfoerste> eval $(echo db2 \$$T)

1
-----------
      23756

  1 record(s) selected.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum