create a new environment variable??


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers create a new environment variable??
# 1  
Old 10-22-2007
create a new environment variable??

Hi,

I have say two programs

File1:

echo Enter A's Value
read A
export A



File2:

while [ $A -ne 20 ]
do
echo $A
sleep 5
done


Now i run File2 in background..

and then i run File1 where i will read value for A

But the message which come's from File2 is not getting changed when i change the value of A in File1 and export it...??

Do i need to creat a new environment varible...?

How do i proceed....
# 2  
Old 10-22-2007
my suggestion is that you have a generic environment file "test.env".
In that file have say ....
TESTVALUE=1

In both scripts you might have the following ...

#!/bin/ksh
##- Environment set-up - As required, comment/uncomment -##
. $HOME/test.env


However in the first script, instead of exporting the you update the environment file with the new value. I think performing something like the following might do the trick:
sed -e "%s/TESTVALUE=.*/TESTVALUE=$A/g"

In the second script and within the loop, make the following call
. $HOME/test.env

This forces the 2nd script to rexecute the details of the environment file.

Hope I've kinda explained that right - starting to nod off - laters Smilie

Cheers,
Cameron
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Lucreate Fails to Create Boot Environment;

My OS solarius 5.10 Generic_147148-2 i86 Error: please review new boots environments using options 1. Solution - show me the commands Partition is full, try to remove some unneeded files, then try to compress some other unneeded files. man command creates a temp file under... (0 Replies)
Discussion started by: zbest1966
0 Replies

2. Shell Programming and Scripting

Expand an environment variable in sed, when the variable contains a slash

I'm trying to make a sed substitution where the substitution pattern is an environment variable to be expanded, but the variable contains a "slash". sed -e 's/<HOME_DIRECTORY>/'$HOME'/'This gives me the following error: sed: -e expression #1, char 21: unknown option to `s'Obviously this is... (2 Replies)
Discussion started by: Ilja
2 Replies

3. Solaris

Environment Variable

Hi All, I am new to SUN Solaris.I have some questions regarding environment variable.:confused: Q1. Where the environment variables available in Solaris. Q2. What command used here. Q3. Can a user change this .Suppose i want to change the bash to ksh can it be possible here. Or i need to... (2 Replies)
Discussion started by: jdash.ps
2 Replies

4. Linux

How to create file on Linux using environment variable in the dirpath

Hi all, I am running a Java program on a Linux server in which I read in a base directory path from the *.properties file. During processing, I build a unique file name and create a file to save data, concatenating the directory path and the file name. Works fine, except that I now need to... (2 Replies)
Discussion started by: patricia1of5
2 Replies

5. Shell Programming and Scripting

about environment variable

i am not clear at some places i saw that assigning a env var with colon ':' like export PATH=/usr/bin:/usr/ucb:/etc:/usr/sbin:.:/usr/platform/sun4u/sbin here you can find : and a . and again : could some one explain how it works... see all is starting from root directory, how : is used and... (6 Replies)
Discussion started by: Arunprasad
6 Replies

6. Solaris

Environment variable

Hello, For the moment, my LC_ALL variable is set as "" by default. If I want to change this value, I do : export LC_ALL="en_fr" for example. That I want to know it's : how can I set by default this value ? I want to save it on my profile in order to get it when I open my session... :confused:... (2 Replies)
Discussion started by: MasterapocA
2 Replies

7. Shell Programming and Scripting

Using Environment Variable

In our current environment we have each of our testing levels on individual servers (running Korn shell). So, there is a server for dev and test, and 2 servers for qa and prod. I have several scripts that utilize a code that is dependant on the server where it resides. While I was the only person... (3 Replies)
Discussion started by: kaiser
3 Replies

8. Shell Programming and Scripting

Environment Variable

First of all I am using C shell. I have a variable destDirectory that holds a path. the path includes an environment variable($user) when I try to execute a command within the script, the $destDirectory gets replaced with the path, but the environment variable is not replaced. I end up... (2 Replies)
Discussion started by: karyn1617
2 Replies

9. UNIX for Dummies Questions & Answers

Environment Variable

$ . oraenv (when i type this at the prompt) ORACLE_SID = ? ( I get this) I understand that . oraenv is a startup script and it has the ENV variable ORACLE_SID. But pls let me know what more it explains and also how to change the env variable here. (2 Replies)
Discussion started by: thumsup9
2 Replies

10. UNIX for Dummies Questions & Answers

Environment Variable

Hello, I need some help to understand system and user environment files, such as .profile and others. I can edit my .profile file in my home directory. What I only touch in this file is the $PATH variable and when I am logged in under a telnet session, the PATH that I specify is used and... (8 Replies)
Discussion started by: jacobsa
8 Replies
Login or Register to Ask a Question