Operating System - HP-UX
1833016 Members
2350 Online
110048 Solutions
New Discussion

Re: Problem in changing my environment variables.

 
Efim Kushnir
Frequent Advisor

Problem in changing my environment variables.

I have the problem in changing my environment variables. After log in as user
"oracle" I need to change some current environment variables, for examle
$ORACLE_HOME. I wrote the script with the strings like that:
export ORACLE_HOME=/oracle9ias ;
echo $ORACLE_HOME;
etc.
But after the finish of the script all environment variables stay the same.
What should I do?
Thanks
Look for the answers, do not stop !
4 REPLIES 4
Heiner E. Lennackers
Respected Contributor

Re: Problem in changing my environment variables.

Hi,

if you just create a script and execute it, it will spawn a new shell, sets the variables for this shell and maybe it subshells. But if the script terminates the shell will be closed and the variable settings are gone.
To set the variables in your current shell, you have to "source" the script:
# . ./script.sh
will source the script into your bourne or korn shell.

Heiner
if this makes any sense to you, you have a BIG problem
Steve Steel
Honored Contributor

Re: Problem in changing my environment variables.

Hi


When you run a script it always forks and thus only higher levels get the values.


To change your local values run as

. script

The decimal point space script inhibits the fork and changes values of your current shell.


Steve Steel
If you want truly to understand something, try to change it. (Kurt Lewin)
Olav Baadsvik
Esteemed Contributor

Re: Problem in changing my environment variables.


Hi,

A modification of an environment-variable
has effect for the current-process and
children of this.
It does not change the value of the same
environment-variable for the parent process.


Regards
olav
SHABU KHAN
Trusted Contributor

Re: Problem in changing my environment variables.

Hi,

Always use a environment sourcing file to source in your environment variables...

Put all your environment variables that you need in a file:

ORACLE_HOME=/apps/oracle
LD_LIBRARY_PATH=/....
etc...

call it oracenv ...

set an alias in your .profile or .alias_profile
alias appora='. /path/to/the/oracenvfile'

After you login as oracle ... just type

appora

at the command prompt, this will source-in all the env variables that you need..

Hope this helps !

Thanks,
Shabu