- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Setting environment variables through script
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Forums
Discussions
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
Community
Resources
Forums
Blogs
- 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
11-16-2006 06:15 PM
11-16-2006 06:15 PM
I am trying to set an environment variable through a script. When the script is executed, it run in a new shell and the environment variable is available only in this child shell. But how to make it available to even the parent shell.
Please give your ideas.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2006 07:07 PM
11-16-2006 07:07 PM
Re: Setting environment variables through script
please see my example:
$ cat e.sh
#!/usr/bin/sh
echo "DATA before = [$DATA]"
. ./f.sh
echo "DATA after = [$DATA]"
$ cat f.sh
#!/usr/bin/sh
DATA="this is new"
export DATA
$ ./e.sh
DATA before = []
DATA after = [this is new]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2006 07:09 PM
11-16-2006 07:09 PM
SolutionYou can do this, using the dot operator.
Create a small shell script that makes the changes to the environment variable, something like this perhaps:
export MY_PATH=~/bin
Name this shell script myscript.sh and then, from a shell prompt, type:
. myscript.sh
(dot space myscript.sh)
This will run the shell script myscript.sh in your current shell.
Regards
Joel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2006 01:30 PM
11-17-2006 01:30 PM
Re: Setting environment variables through script
$ resize
COLUMNS=80;
LINES=36;
export COLUMNS LINES;
Resize just echoes some commands. Then you just use the eval builting:
$ eval $(resize)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2006 04:42 PM
11-19-2006 04:42 PM