- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Loading a new environment from a file
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
03-30-2006 09:57 AM
03-30-2006 09:57 AM
the doubt in question is:
I hava a user own csh
I need work with ksh
I know that i have change kind of shell in /usr/passwd file in kind of shell field, but i do not have password root and we do not know it ..
for above told, i'm using /usr/bin/ksh in the beginning of the scripts
i'm testing follows:
i created a file which contanins a file which contantains only variables set.
but, when i run script variables are not set and if i execute the line into script over prompt can works without problems, i mean, variables are set ...
why?
Script which has variables set:
named: environment
contains:
a="/home/usera"
b="/home/userb"
c="/home/userc"
other script which run above file:
named: test
contains follows:
echo "step1"
. /home/environment
echo "step1"
well ..
i logon ...
i run ksh to enter ksh environment
i run step1
appears:
step1
step2
if i test:
echo $a
do not shown something !!!!
why!!!
if i run online:
. /home/environment
and then verify environment as follows:
echo $a
appears:
/home/usera
why!!!
doubt here is , if i run environment file from a file, why do not work????
help please ..
thanks, Manuales ..
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2006 10:04 AM
03-30-2006 10:04 AM
Solutionyou need to add this at the end of your environment script:
export a b c
You also need to make absolutely certain that you do this:
. /home/environment
rather than
./home/environment
In the first case, the "." sources the file and it becomes part of the current process; in the second case, the file is run as a child process and a child can never alter the environment of a parent. A sourced file can also not contain a return or exit statement because the effect is to exit the foreground process.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2006 10:09 AM
03-30-2006 10:09 AM
Re: Loading a new environment from a file
. /home/environment
besides are you testing at the command prompt after the subshell has finished executing your script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2006 10:20 AM
03-30-2006 10:20 AM
Re: Loading a new environment from a file
Doing other test:
i'm login with csh user
i have a file named environment
which contains:
set a=/home/usera
if in command line i run:
set a=/home/usera
and if i run:
echo $a
appears: /home/usera
but ...
if i save this command line in a file named environment_into_file as follows:
cat enviroment_into_file
. /home/environment
and if i run environment_into_file
do not run!!! if i run echo $a after run environment_into_file do not work because do not show valu variable "a" !!!
why !!!
SOS PLEASE !!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2006 10:27 AM
03-30-2006 10:27 AM
Re: Loading a new environment from a file
For example
export XX=0 in POSIX
would be
setenv XX 0 in csh
The use of csh is generally discouraged these days.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2006 10:43 AM
03-30-2006 10:43 AM
Re: Loading a new environment from a file
i have updated "environment" file follows:
setenv a /home/usera
file test contents:
. /home/environment
if i run appears follows:
test[2]: setenv: not found.
why !!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2006 10:44 AM
03-30-2006 10:44 AM
Re: Loading a new environment from a file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2006 10:48 AM
03-30-2006 10:48 AM
Re: Loading a new environment from a file
. environment_into_file
then do an echo $a
cheers!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2006 11:01 AM
03-30-2006 11:01 AM
Re: Loading a new environment from a file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2006 11:47 AM
03-30-2006 11:47 AM
Re: Loading a new environment from a file
chsh user_name /usr/bin/ksh
To answer your question, is the POSIX shell the same as ksh? The answer is yes other than some obscure features. The POSIX shell is /usr/bin/sh.
If you have scripts the start with:
#!/usr/bin/ksh
these scripts can be run from the csh shell. That first line tells the current shell what program to use to interpret this shell script. Note that whenever you run a script normally, everything takes place in a sub=program. Whatever happens in this sub-program has no effect on the current shell. That's why you must use the . followed by a space to have the shell interpret the script without a subprogram.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2006 11:48 AM
03-30-2006 11:48 AM
Re: Loading a new environment from a file
A Posix shell conforms to to the specifications of the POSIX.2 Shell and Utility standards.
Posix shells build on the Korn shell originally developed at AT&T by David Korn. Sprinkled in the Posix shell are some of the features of the C-shell ('csh') as originally written by Bill Joy. Together, this ancestry evolves into a formal standard that any Posix-complaint shell must meet.
On HP-UX, the standard POSIX shell resides in '/sbin/sh' (as statically linked code) and in '/usr/bin/sh' (using dynamically linked libraries).
The 'ksh' shell on HP-UX found in '/usr/bin/ksh' is a Korn-88 version. It is not Posix compliant. A more modern, Korn-93 version with more Posix compliance lives in '/usr/dt/bin/dtksh'.
If you examine the end of the 'sh-poxix' man pages you can begin to get a sense of the standards that are established to describe conformance. If you really want to know more, begin here:
http://www.opengroup.org/onlinepubs/009695399/toc.htm
Regards!
...JRF...