HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Embarrassingly simple env variable question
Operating System - HP-UX
1833059
Members
2662
Online
110049
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
Go to solution
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
07-02-2002 10:55 AM
07-02-2002 10:55 AM
I am a little embarrassed to post this...but here goes
I have a script to change env variables but it is not working. I believe it is set up identical to my .profiles, yet a check of the variable using echo indicates they are not changed.
TESTSETTINGS=defaultconfig.test
export TESTSETTINGS
SERVERNAME=HP9K_serv01
export SERVERNAME
echo $ yields the original .profile settings.
tia
Doug
I have a script to change env variables but it is not working. I believe it is set up identical to my .profiles, yet a check of the variable using echo indicates they are not changed.
TESTSETTINGS=defaultconfig.test
export TESTSETTINGS
SERVERNAME=HP9K_serv01
export SERVERNAME
echo $ yields the original .profile settings.
tia
Doug
Solved! Go to Solution.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2002 11:01 AM
07-02-2002 11:01 AM
Re: Embarrassingly simple env variable question
Hi Doug,
The env vars you set in the script are only available to the script or any children it spawns. They cannot be easily passed back to the parent - the shell that runs the script in your case.
Try echoing them inside the script to see their true value while in the script.
Rgds,
Jeff
The env vars you set in the script are only available to the script or any children it spawns. They cannot be easily passed back to the parent - the shell that runs the script in your case.
Try echoing them inside the script to see their true value while in the script.
Rgds,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2002 11:01 AM
07-02-2002 11:01 AM
Re: Embarrassingly simple env variable question
Hi Doug,
If you calling another file from your .profile, use this syntax,
. /path_to_file/file_name
Then do a check for the env variable,
echo $SERVERNAME
Hope this helps.
Regds
If you calling another file from your .profile, use this syntax,
. /path_to_file/file_name
Then do a check for the env variable,
echo $SERVERNAME
Hope this helps.
Regds
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-02-2002 11:07 AM
07-02-2002 11:07 AM
Solution
Hi Doug:
Let me see if this is what you are doing.
Originally in your .profile
XXX=000
YYY=111
export XXX YYY
You created a script, env.sh that does this
XXX=888
YYY=999
export XXX YYY
You then
env.sh
echo $XXX
and you see "000" rather than the expected "888".
------------------------------------------
There is nothing wrong with your code but you are trying to change the parent's env from a child; that dog won't hunt.
What you can do is SOURCE env.sh.
. env.sh
The '.' remains in the foreground and is part of the current shell. You must make certain that your sourced script does not contain an exit or return or you will of cource exit your current (foreground) process.
Regards, Clay
Let me see if this is what you are doing.
Originally in your .profile
XXX=000
YYY=111
export XXX YYY
You created a script, env.sh that does this
XXX=888
YYY=999
export XXX YYY
You then
env.sh
echo $XXX
and you see "000" rather than the expected "888".
------------------------------------------
There is nothing wrong with your code but you are trying to change the parent's env from a child; that dog won't hunt.
What you can do is SOURCE env.sh.
. env.sh
The '.' remains in the foreground and is part of the current shell. You must make certain that your sourced script does not contain an exit or return or you will of cource exit your current (foreground) process.
Regards, Clay
If it ain't broke, I can fix that.
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