- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Environment variable changes in a csh script
Operating System - HP-UX
1760078
Members
2412
Online
108889
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
Discussions
Discussions
Forums
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
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
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
тАО04-12-2002 02:45 PM
тАО04-12-2002 02:45 PM
Environment variable changes in a csh script
We have database environment variables set as part of our .cshrc for a login. When that same person changes his environment variables and runs a csh script the csh script reverts his changed environment variables back to the same that .cshrc sets. Any ideas on this one? Thanks all!
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-12-2002 03:07 PM
тАО04-12-2002 03:07 PM
Re: Environment variable changes in a csh script
Unless they are set in the script, when you invoke another shell it will use .cshrc.
My .02. Been burned by this.
Best of luck.
dl
My .02. Been burned by this.
Best of luck.
dl
"I'm not dumb. I just have a command of thoroughly useless information."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-12-2002 03:23 PM
тАО04-12-2002 03:23 PM
Re: Environment variable changes in a csh script
Hi Todd:
You need to set and export the environmental variables you want visible:
# setenv MYTHING myvalue
Regards!
...JRF...
You need to set and export the environmental variables you want visible:
# setenv MYTHING myvalue
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-12-2002 11:43 PM
тАО04-12-2002 11:43 PM
Re: Environment variable changes in a csh script
The problem here is called inheritance. A process may inherit its environment from its parent but can pass nothing back.
This is why you have the differences between running a shell and sourcing a shell.
When you 'run' a shell script, a new copy of the shell is spawned and the script is run in this new spawned - ie no effect to the environment of the current shell.
When you 'source' a shell script, it is loaded and executed in the current shell - therfore it will effect the current environment.
For example (using /usr/bin/sh - csh is evil and shouldn't be used :-)
$ cat env.sh
#!/usr/bin/sh
FRED="a value"
$ FRED=""
$ ./env.sh
$ echo ${FRED}
$ . ./env.sh
$ echo ${FRED}
a value
$
It's similar in csh - except you can use the keyword 'source' instead of a . eg:
% source ./env.sh
% echo $FRED
a value
%
HTH
dave
This is why you have the differences between running a shell and sourcing a shell.
When you 'run' a shell script, a new copy of the shell is spawned and the script is run in this new spawned - ie no effect to the environment of the current shell.
When you 'source' a shell script, it is loaded and executed in the current shell - therfore it will effect the current environment.
For example (using /usr/bin/sh - csh is evil and shouldn't be used :-)
$ cat env.sh
#!/usr/bin/sh
FRED="a value"
$ FRED=""
$ ./env.sh
$ echo ${FRED}
$ . ./env.sh
$ echo ${FRED}
a value
$
It's similar in csh - except you can use the keyword 'source' instead of a . eg:
% source ./env.sh
% echo $FRED
a value
%
HTH
dave
- Tags:
- scummy C shell
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.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP