get env variable from last script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting get env variable from last script
# 8  
Old 02-04-2009
Quote:
Originally Posted by honglus
it didn't work,

What does "didn't work" mean? What is the output of:

Code:
printf "%s\n" "$INSTANCE"

Quote:
let me put in the other way

Code:
 
/tmp/test$ cat t3.sh 
#!/bin/bash
INSTANCE="font/fc-cache"
var=\$\{INSTANCE\}
echo $var
 
/tmp/test$ ./t3.sh 
${INSTANCE}

it outputs ${INSTANCE}, but i need outputs "font/fc-cache".

The code I posted doesn't output anything. What did you add to produce output?
Quote:

don't change this:"var=\$\{INSTANCE\} and i don't know the name INSTANCE.
# 9  
Old 02-04-2009
Quote:
Originally Posted by cfajohnson
thanks, maybe you didn't understand my meaning, but anyway i have made it work by assigning to new variable by eval

Code:
 
/tmp/test$ cat t3.sh 
#!/bin/bash
INSTANCE="font/fc-cache"
var=\$\{INSTANCE\}
eval x=$var
echo $x
/tmp/test$ ./t3.sh 
font/fc-cache

# 10  
Old 02-04-2009
Quote:
Originally Posted by honglus
thanks, maybe you didn't understand my meaning, but anyway i have made it work by assigning to new variable by eval

Code:
 
/tmp/test$ cat t3.sh 
#!/bin/bash
INSTANCE="font/fc-cache"
var=\$\{INSTANCE\}
eval x=$var
echo $x
/tmp/test$ ./t3.sh 
font/fc-cache


That doesn't bear any resemblance to what you have been asking.

It is also redundant.

Why do you not just echo $INSTANCE?:

Code:
#!/bin/bash
INSTANCE=font/fc-cache
echo "$INSTANCE"

That does exactly the same as your bloated code.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Treat value of variable as env variable

Hi All, I have a requirement where I have a config file, which contains 2 coulmn.values of first column are environmnet variable, whose value is defined in an environment file. In my script I need to read the config file, and get the value of the config file variable from env file. I... (2 Replies)
Discussion started by: alok2082
2 Replies

2. Shell Programming and Scripting

Bash script - ENV Variable context problem using su

Hello I have found some piece of code to verify and then run shell script with root permission from normal user. see : http://blog.mecworks.com/articles/2006/02/23/bash-scripting-tip-running-a-script-as-root I have wrote two scripts using this tips. - one to copy file from server to local... (6 Replies)
Discussion started by: jcdole
6 Replies

3. Web Development

Deny from env=env-variable Does not work

(Above from Apache docs). On my system, using: SetEnvIf User-Agent Mozilla IsBad=1 Order allow,deny Allow from all Deny from env=IsBad ...I see that environment variable is set (using phpinfo()) but the page is still served. No errors in the Apache logs. (1 Reply)
Discussion started by: gnurob
1 Replies

4. Shell Programming and Scripting

how to set/get shell env variable in python script

greetings, i have a sh script that calls a python script. the sh script sets an env variable BIN: export BIN=bin64i need to get that BIN variable's value and use it within this python script. anyone know how to do this? thanx in advance. (5 Replies)
Discussion started by: crimso
5 Replies

5. Solaris

Env variable in solaris

Hi, Am installing SAP on Solaris 10. How to set env variables permanently? Reg (0 Replies)
Discussion started by: daggupati453
0 Replies

6. Shell Programming and Scripting

Env variable

Hello, I want to cange env variable on SunOS. I tried: export GONGA=$GONGA:/users/BANK1/basic/queues/SARON_SPACE1 it changed it only localy for my session. when i opened a new session (telnet etc') the old value exist. How can I change it to effact all sessions. Thanks. (2 Replies)
Discussion started by: LiorAmitai
2 Replies

7. Shell Programming and Scripting

Set/Export Env Vars from with Shell Script With Input Variable

I have a shell script I want to run that will set environment variables based on the value of an input variable submitted when the shell script is called. For example: $ mgenv.sh prod This would set environment variables for prod $ mgenv.sh test This would set environment variables... (1 Reply)
Discussion started by: brtaylor73
1 Replies

8. UNIX for Dummies Questions & Answers

Env Variable

Hi, I have a doubt on Environment variable. I want to know where and when the envirnment variables are defined? Thanks & Regards, Siba (1 Reply)
Discussion started by: siba.s.nayak
1 Replies

9. UNIX for Dummies Questions & Answers

PWD env variable

Could you please tell me, which process / file is responsible for the setting of PWD env variable in Solaris Thanks (1 Reply)
Discussion started by: chaandana
1 Replies

10. Shell Programming and Scripting

bash env variable containing @

I want to set a bash env variable which has @ in its name, for example, @YOGESH@ may i know how do i do this? (4 Replies)
Discussion started by: Yogesh Sawant
4 Replies
Login or Register to Ask a Question