HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: updating a environment var without re-exportin...
Operating System - HP-UX
1829713
Members
2720
Online
109992
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2005 05:51 AM
03-11-2005 05:51 AM
updating a environment var without re-exporting it
Folks,
In posix shell, Is there a way to have an environment variable inherit the value of another variable as it changes? i.e., if
export VAR1=/foo/bar
and
export VAR2=$VAR1
then
$VAR2=/foo/bar
if VAR1 changes then I need to re-export VAR2 to get the new value and I don't want to do that.
I'm looking for a way that works similar to PS1, which will inherit changes.
What I'm really trying to do is set up a bunch of different oracle environments that will change based on the value of SID and ORACLE_HOME. The only way I can think of involves aliases and each of these is getting very long.
Thanks,
Chuck Davis
In posix shell, Is there a way to have an environment variable inherit the value of another variable as it changes? i.e., if
export VAR1=/foo/bar
and
export VAR2=$VAR1
then
$VAR2=/foo/bar
if VAR1 changes then I need to re-export VAR2 to get the new value and I don't want to do that.
I'm looking for a way that works similar to PS1, which will inherit changes.
What I'm really trying to do is set up a bunch of different oracle environments that will change based on the value of SID and ORACLE_HOME. The only way I can think of involves aliases and each of these is getting very long.
Thanks,
Chuck Davis
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2005 06:11 AM
03-11-2005 06:11 AM
Re: updating a environment var without re-exporting it
Hi,
I don't belive this is possible without starting a new shell (and use a ENV file).
I don't belive this is possible without starting a new shell (and use a ENV file).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2005 06:24 AM
03-11-2005 06:24 AM
Re: updating a environment var without re-exporting it
I'm not sure if there is a way to automatically
change VAR2 when VAR1 changes. One
"workaround" would be to write a function which
resets VAR2 and should be called everytime you
modify VAR1. Something like:
reset_var ()
{
VAR2=$VAR1
}
VAR1="str1";reset_var
.. your script here
VAR1="str2";reser_var
.. some more of your ascript here...
- Biswajit
change VAR2 when VAR1 changes. One
"workaround" would be to write a function which
resets VAR2 and should be called everytime you
modify VAR1. Something like:
reset_var ()
{
VAR2=$VAR1
}
VAR1="str1";reset_var
.. your script here
VAR1="str2";reser_var
.. some more of your ascript here...
- Biswajit
:-)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2005 09:04 AM
03-15-2005 09:04 AM
Re: updating a environment var without re-exporting it
thanks for the input. It was as I suspected. to keep it simple for the users I ended up writing an alias that calls a function and also sets/clears some environment variables.
fwiw, it goes like this:
ora_env () #this function is run each time the SID alias (defined below) is invoked
{
export ORACLE_BASE=${ORA_APP}/admin
export ORACLE_HOME=${ORA_APP}/product/${ORA_VER}
export SHLIB_PATH=${SHLIB_PATH}:${ORACLE_HOME}/lib32:/usr/lib
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${ORACLE_HOME}/lib
unset SP_SYS_VARDIR
} #end function ora_env
alias mast='export ORACLE_SID=mast;\
export ORA_VER=9.0.1.0;\
export ORA_APP=/data0/app/oracle;\
ora_env
export SP_SYS_VARDIR=/data0/splex/var;\
export PATH=$PATH:/data0/splex/prod/bin'
alias ioct='export ORACLE_SID=ioct;\
export ORA_VER=9.0.1.0;\
export ORA_APP=/data0/app/oracle;\
ora_env'
alias mast21='export ORACLE_SID=mast21;\
export ORA_VER=9.0.1.0;\
export ORA_APP=/data0/app/oracle;\
ora_env'
alias prod='export ORACLE_SID=prod;\
export ORA_VER=8.1.7;\
export ORA_APP=/usr0/app/oracle;\
ora_env'
alias wrstest='export ORACLE_SID=wrstest;\
export ORA_VER=8.1.7;\
export ORA_APP=/usr0/app/oracle;\
ora_env'
---
This info is in a separate script that is sourced by /etc/profile. The user needs to only type the sid name and the variables will be set accordingly. Main drawback is the PATH can get redundant settings tacked to it. If this becomes a problem then I may throw a little sed in the function to clean it up.
Regards,
Chuck Davis
fwiw, it goes like this:
ora_env () #this function is run each time the SID alias (defined below) is invoked
{
export ORACLE_BASE=${ORA_APP}/admin
export ORACLE_HOME=${ORA_APP}/product/${ORA_VER}
export SHLIB_PATH=${SHLIB_PATH}:${ORACLE_HOME}/lib32:/usr/lib
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${ORACLE_HOME}/lib
unset SP_SYS_VARDIR
} #end function ora_env
alias mast='export ORACLE_SID=mast;\
export ORA_VER=9.0.1.0;\
export ORA_APP=/data0/app/oracle;\
ora_env
export SP_SYS_VARDIR=/data0/splex/var;\
export PATH=$PATH:/data0/splex/prod/bin'
alias ioct='export ORACLE_SID=ioct;\
export ORA_VER=9.0.1.0;\
export ORA_APP=/data0/app/oracle;\
ora_env'
alias mast21='export ORACLE_SID=mast21;\
export ORA_VER=9.0.1.0;\
export ORA_APP=/data0/app/oracle;\
ora_env'
alias prod='export ORACLE_SID=prod;\
export ORA_VER=8.1.7;\
export ORA_APP=/usr0/app/oracle;\
ora_env'
alias wrstest='export ORACLE_SID=wrstest;\
export ORA_VER=8.1.7;\
export ORA_APP=/usr0/app/oracle;\
ora_env'
---
This info is in a separate script that is sourced by /etc/profile. The user needs to only type the sid name and the variables will be set accordingly. Main drawback is the PATH can get redundant settings tacked to it. If this becomes a problem then I may throw a little sed in the function to clean it up.
Regards,
Chuck Davis
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP