- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: A strange thing in HP-UX
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
Discussions
Discussions
Forums
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
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
тАО09-24-2001 10:26 PM - last edited on тАО11-22-2012 07:33 PM by Cathy_xu
тАО09-24-2001 10:26 PM - last edited on тАО11-22-2012 07:33 PM by Cathy_xu
A strange thing in HP-UX
when i execute a shell command file,in that file i set some enviroment variables and exports them,it works right when it's being executed.
but when the shell file is over,that exported enviroment variables dispear also.
if i execute the file using " . filename ",
it do what i want,that is why??
P.S.This thread has been moved from HP-UX >General to HP-UX > languages- HP Forums Moderator
- Tags:
- variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-24-2001 10:36 PM
тАО09-24-2001 10:36 PM
Re: A strange thing in HP-UX
normally when we run script with filename
another shell will fork and when it finish , it will return back to current shell and all exported variable was gone.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-24-2001 10:42 PM
тАО09-24-2001 10:42 PM
Re: A strange thing in HP-UX
The variables that are exported as part of the
script run as a completely seperate process
and are not part of your shell environment, so
when the script completes, the variables
that are associated with script complete also.
If you want to add them to your own env, add
them to either your own .profile or .login or
the file associated with the sheel you are using.
HTH
-Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-24-2001 10:50 PM
тАО09-24-2001 10:50 PM
Re: A strange thing in HP-UX
There are two types of variable in HPUX. One is environment variable and other is shell variable. Shell variables are applicable only to that shell. Not visible to parents.
If U are executing a script in a new shell, the all variable set in that script will be applicable only to that new shell. Once U come out of the script, that shell will get closed. Means ur variables also disappears.
Whenever U are executing a script from the parent shell (like ./script), U are not creating a new shell. the changes will reflect here and it will make changes in environment variables.
Best of luck
Shahul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-25-2001 01:02 AM
тАО09-25-2001 01:02 AM
Re: A strange thing in HP-UX
thanks for yr helps.but i still has a little annoy about it.
when i want to set some Env variavles,then
i has to modify the .profile only?
because when i use Weblogic, there is always a file "setEnv.sh",so i has to run it using ". setEnv.sh"??
huomzh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-25-2001 01:29 AM
тАО09-25-2001 01:29 AM
Re: A strange thing in HP-UX
. setEnv.sh
If you need to have this set all the time, then yes, you'd have this statement in your ~/.profile so that it gets sourced every time you log in.
The reason that these settings don't stay when you execute the script is that when you execute the script, it spawns a subshell, sets up everything in the subshell and then exits the subshell effectively leaving you where you started, i.e. without the setting.
-Santosh