- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: changing environment variables
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
тАО11-22-2000 08:05 AM
тАО11-22-2000 08:05 AM
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-22-2000 08:11 AM
тАО11-22-2000 08:11 AM
Re: changing environment variables
An environment variable is known in the current script and the child scripts if it's been exported.
If you vant the calling script to maintain the value of a variable exported in a child, you should "source" the child script.
Example:
in csh:
source my_script
in bourne, korn or posix shells
. my_script
(
This forces reading all variables in the currently executing shell
Cheers
Dan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-22-2000 08:14 AM
тАО11-22-2000 08:14 AM
Re: changing environment variables
What you need to do is put all your environment variables in to a file.
For Eg:-
You have a set of variable for environment A in a file called "enva" and for environment B in a file called "envb"
Upon selection by the user execute the environment file as follows:
. envb # ( remember to put a dot before the command with a space as given here )
Above execution will set the variable in the current session.
Regards,
Pramod
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-22-2000 08:14 AM
тАО11-22-2000 08:14 AM
Re: changing environment variables
If you want the environment to remain, you have to "dot" the script ie.
# . /path/to/script
what this does is that it reads the script and executes it within the current shell without spawning a new process to execute it.
The parent process (ie. the shell) cannot be modified by a child process - you can only do it by "exec'ing" or "dot"ing the script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-22-2000 12:20 PM
тАО11-22-2000 12:20 PM
Re: changing environment variables
alias env1="QTHOME=
alias env2="QTHOME=
insert these lines into /etc/profile or $HOME/.profile
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-22-2000 12:20 PM
тАО11-22-2000 12:20 PM
Re: changing environment variables
alias env1="QTHOME=
alias env2="QTHOME=
insert these lines into /etc/profile or $HOME/.profile
then you be able to change QTHOME with simply entering
env1
or
env2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-22-2000 12:55 PM
тАО11-22-2000 12:55 PM
Re: changing environment variables
Some more details:
The $QTHOME variable is set with the setenv command in the logins to /opt/qtime/qt/v5e.5c.
I wanted them to switch to the new version to test, which means they need to set $QTHOME to /opt/qtime/qt/v5.7. If they run changeqver.sh, it asks them which version they want to run, and does a setenv to the appropriate $QTHOME.
I've put the setenv commands into a separate file, and have changed the changeqver.sh to source the appropriate file, but it still doesn't work. Using a . setqver just gives me a permission denied message (permission denied /opt/pd/.)
All users are using the csh.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-22-2000 01:07 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-23-2000 02:04 AM
тАО11-23-2000 02:04 AM
Re: changing environment variables
alias changeqver "source changeqver.sh"
add this line into /etc/csh.login or $HOME/.login
so the usesr only have to type changeqver and get their correct variable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-23-2000 04:18 AM
тАО11-23-2000 04:18 AM
Re: changing environment variables
I said it previously, if you are using csh, you should source the script file containing the variable definitions.
example:
source changeqver.sh
or, as Rainer suggested, use an alias
alias changeqver "source changeqver.sh"
Make sure that in changeqver.sh, all variables are defined using the csh syntax for environment variables, ie 'setenv my_var value'
This has been working for ages, there's no reason for not working in your scripts.
Best regards,
Dan