- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Environment variable setup using export failed...
Operating System - Linux
1748211
Members
4928
Online
108759
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
Discussions
Discussions
Forums
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
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
тАО09-11-2007 11:53 PM
тАО09-11-2007 11:53 PM
HI,
I have a short script below to set some environment variables.
#!/bin/sh
export GATEWAY_ROOT=/prodkl/working/huawei_nss/V33
export GATEWAY_FRAMEWORK=/prodkl/working/GATEWAY_FRAMEWORK
export GATEWAY_CONFIG=/prodkl/working/3rd_LINE/huawei_nss/V33/GATEWAY_CONFIG
export VENDOR_GATEWAY=/prodkl/working/3rd_LINE/huawei_nss/V33/VENDOR_GATEWAY
export PERL5_BASE=/prodkl/working/3rd_LINE/PERL5_BASE
export TZ=GMT+8
However, executing the script does not seem to set the environment variables.
bash-3.00$ echo $TZ
bash-3.00$ echo $GATEWAY_CONFIG
bash-3.00$ echo $VENDOR_GATEWAY
bash-3.00$ echo $GATEWAY_ROOT
May I understand where did go wrong?
Thanks
Danny.
I have a short script below to set some environment variables.
#!/bin/sh
export GATEWAY_ROOT=/prodkl/working/huawei_nss/V33
export GATEWAY_FRAMEWORK=/prodkl/working/GATEWAY_FRAMEWORK
export GATEWAY_CONFIG=/prodkl/working/3rd_LINE/huawei_nss/V33/GATEWAY_CONFIG
export VENDOR_GATEWAY=/prodkl/working/3rd_LINE/huawei_nss/V33/VENDOR_GATEWAY
export PERL5_BASE=/prodkl/working/3rd_LINE/PERL5_BASE
export TZ=GMT+8
However, executing the script does not seem to set the environment variables.
bash-3.00$ echo $TZ
bash-3.00$ echo $GATEWAY_CONFIG
bash-3.00$ echo $VENDOR_GATEWAY
bash-3.00$ echo $GATEWAY_ROOT
May I understand where did go wrong?
Thanks
Danny.
Solved! Go to Solution.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-12-2007 01:08 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-12-2007 01:52 AM
тАО09-12-2007 01:52 AM
Re: Environment variable setup using export failed to setup env variables
As menthined by Oviwan, the problem is that the variables are set into a new shell (#!/bin/bash), then the script finishes and the shell ends.
To avoid this, and set the variables to your current shell, remove the first line and run:
. shell.sh
This is dot, space, shell.sh. Or you can use:
source shell.sh
This will load the variables into your current shell.
To avoid this, and set the variables to your current shell, remove the first line and run:
. shell.sh
This is dot, space, shell.sh. Or you can use:
source shell.sh
This will load the variables into your current shell.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-12-2007 02:04 AM
тАО09-12-2007 02:04 AM
Re: Environment variable setup using export failed to setup env variables
Hi Danny:
The key is to source (read) your script but not run it as a separate shell where its variables cannot be seen or propagated to parent shell.
Hence:
#!/bin/sh
echo "I am the parent script"
. myenv.sh #...NOTE the DOT then WHITESPACE followd by the file name!
echo "my GATEWAY_ROOT is ${GATEWAY_ROOT}"
This is WRONG:
...
myenv.sh
echo "my GATEWAY_ROOT is ${GATEWAY_ROOT}"
...
Regards!
...JRF...
The key is to source (read) your script but not run it as a separate shell where its variables cannot be seen or propagated to parent shell.
Hence:
#!/bin/sh
echo "I am the parent script"
. myenv.sh #...NOTE the DOT then WHITESPACE followd by the file name!
echo "my GATEWAY_ROOT is ${GATEWAY_ROOT}"
This is WRONG:
...
myenv.sh
echo "my GATEWAY_ROOT is ${GATEWAY_ROOT}"
...
Regards!
...JRF...
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.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP