- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: env variable from a 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
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
04-14-2005 07:09 AM
04-14-2005 07:09 AM
I put the export command or the alias command but it does not works.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2005 07:29 AM
04-14-2005 07:29 AM
Re: env variable from a script
Example, csh vs bash
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2005 07:39 AM
04-14-2005 07:39 AM
Re: env variable from a script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2005 08:24 AM
04-14-2005 08:24 AM
Re: env variable from a script
If I try to set an env variable at command line it works. If I set an env from a '.' file it works. If I set an env variable from regular file it doesn't work
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2005 08:40 AM
04-14-2005 08:40 AM
Re: env variable from a script
As stated, I make a file called 'test' and in this file I put 'CITY=LA;export CITY'. I cannot get the $CITY value.
If I rename this file to .test (same contents) and execute this file the env variable of `echo $CITY` is LA.
As stated, I do not believe this correct is how it works.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2005 12:55 PM
04-14-2005 12:55 PM
SolutionIn bash, you call an alias or a script.. it spawns off a sub-shell. The subshell protect's the parents environment space.
Most (if not all) linux based shells do this for security reasons. There are a few that don't (some versions of pdksh for instance).
To set the environment in the current shell, you either have to use '. <script>' commands, or set them manually.
What exactally are you trying to do?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2005 10:25 PM
04-14-2005 10:25 PM
Re: env variable from a script
. ./test
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2005 03:16 AM
04-15-2005 03:16 AM
Re: env variable from a script
I want a script which can change several environment variables. And I want to invoke this scripts from everywhere I was in the directory hierarchie.
This is, wherever I am, I want to change several (defined) environment variables just typing a single word (command, name of the scripts, etc.).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2005 11:36 AM
04-15-2005 11:36 AM
Re: env variable from a script
In your profile/bash profile, set up the function do do what you require:
function name() {
command
command
command
}
And run 'name' when you need it. It changes the current shell's environment.
See 'man bash', the secion on 'FUNCTIONS'.