HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: export in scripts
Operating System - HP-UX
1833162
Members
3482
Online
110051
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
10-13-2009 08:42 AM
10-13-2009 08:42 AM
Why do people use export with variables in scripts? I can only assume it is to set the environment variables. Are the exports temporary just until the process stops running? I am trying to gain a better understanding on the use of export in scripts.
Examples are below.
export ORACLE_HOME=/oracle/app/product/forms9i
export TWO_TASK=ID
export TERM=vt100
Examples are below.
export ORACLE_HOME=/oracle/app/product/forms9i
export TWO_TASK=ID
export TERM=vt100
Solved! Go to Solution.
- Tags:
- export
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2009 08:50 AM
10-13-2009 08:50 AM
Solution
Hi:
Yes, one 'export's a variable from a script to propagate it into any child environment.
Yes, the environment exists only for the lifetime of the process and any child processes that inherit the environmental content.
One way to pass variables from one script to another is to "source" or read a file:
# cat /tmp/A
#!/usr/bin/sh
fruit=apple
# cat /tmp/B
#!/usr/bin/sh
. /tmp/A
echo "I want a(n) ${fruit}"
# /tmp/B
I want a(n) apple
...Note the dot character; followed by whitespace; followed by the script to be "sourced" (read). In this case, the variables declared in "A" are only available to "B" for its use.
Regards!
...JRF...
Yes, one 'export's a variable from a script to propagate it into any child environment.
Yes, the environment exists only for the lifetime of the process and any child processes that inherit the environmental content.
One way to pass variables from one script to another is to "source" or read a file:
# cat /tmp/A
#!/usr/bin/sh
fruit=apple
# cat /tmp/B
#!/usr/bin/sh
. /tmp/A
echo "I want a(n) ${fruit}"
# /tmp/B
I want a(n) apple
...Note the dot character; followed by whitespace; followed by the script to be "sourced" (read). In this case, the variables declared in "A" are only available to "B" for its use.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2009 08:53 AM
10-13-2009 08:53 AM
Re: export in scripts
Exporting a variable makes it available to child processes.
Easily demonstrated in a shell:
babylon-4:itrc wout$ echo $TEST
value
babylon-4:itrc wout$ sh
sh-3.2$ echo $TEST
sh-3.2$ exit
exit
babylon-4:itrc wout$ export TEST
babylon-4:itrc wout$ sh
sh-3.2$ echo $TEST
value
Cheers
Wout
Easily demonstrated in a shell:
babylon-4:itrc wout$ echo $TEST
value
babylon-4:itrc wout$ sh
sh-3.2$ echo $TEST
sh-3.2$ exit
exit
babylon-4:itrc wout$ export TEST
babylon-4:itrc wout$ sh
sh-3.2$ echo $TEST
value
Cheers
Wout
an engineer's aim in a discussion is not to persuade, but to clarify.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2009 09:20 AM
10-13-2009 09:20 AM
Re: export in scripts
Thanks for the quick replies very helpful.
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