Google Skupine ne podpirajo več novih objav ali naročnin v storitvi Usenet. Zgodovinsko vsebino si je še vedno mogoče ogledati.
Dismiss

Bash env settings problems

17 ogledov
Preskoči na prvo neprebrano sporočilo

Ricky

neprebran,
26. jun. 2008, 13:30:1226. 6. 08
do
Hi all
i m becoming mad for this issue on a Solaris 10 box:
I'll explain with some easy output

machine{root}:/bin $ su - orausr
machine{orausr}:~>env
MANPATH=:/usr/openwin/man:/usr/man:/usr/share/man:/usr/local/man:/opt/
VRTS/man
....
lot of environment
....
ORACLE_SID=ABC

Comment:
The user "orausr" has a /bin/bash shell so, giving "su - orausr" I
tell the sytem to switch to user "orausr" with a login shell.
As expected bash read its configuration file "~./profile" to set the
user env.
Inside .profile there is a line like this.
source ~/.bashrc
So .profile calls .bashrc..
The ORACLE_SID env var comes from .bashrc ..
All environment is placed inside .bashrc , and .profile calls it.
So login shells should call .profile and non-login ones should call
directly .bashrc

Til now all is running fine..

Now i try this:

su - orausr -c "env"
-bash-3.2$ env
HZ=
SHELL=/bin/bash
TERM=xterm
MAIL=/var/mail/orausr
PATH=/usr/bin:
PWD=/oracle...
LANG=C
TZ=Europe/Rome
SHLVL=1
HOME=/oracle..
LOGNAME=orausr
_=/usr/bin/env

I expect that bash runs the environment from .bashrc ...but nothing
append...
From "man bash" page:

"
INVOCATION
A login shell is one whose first character of argument zero
is a -, or one started with the --login option.

An interactive shell is one started without non-option argu-
ments and without the -c option whose standard input and
error are both connected to terminals (as determined by
isatty(3)), or one started with the -i option. PS1 is set
and $- includes i if bash is interactive, allowing a shell
script or a startup file to test this state.

The following paragraphs describe how bash executes its
startup files. If any of the files exist but cannot be
read, bash reports an error. Tildes are expanded in file
names as described below under Tilde Expansion in the EXPAN-
SION section.

When bash is invoked as an interactive login shell, or as a
non-interactive shell with the --login option, it first
reads and executes commands from the file /etc/profile, if
that file exists. After reading that file, it looks for
~/.bash_profile, ~/.bash_login, and ~/.profile, in that
order, and reads and executes commands from the first one
that exists and is readable. The --noprofile option may be
used when the shell is started to inhibit this behavior.

When an interactive shell that is not a login shell is
started, bash reads and executes commands from ~/.bashrc, if
that file exists. This may be inhibited by using the --norc
option. The --rcfile file option will force bash to read
and execute commands from file instead of ~/.bashrc.
"

Where am I doing wrong?

Thank you for your support!

Ricky

PS : This work
su - orausr -cl "env"
But it doesnt fit my case!

Rowley

neprebran,
27. jun. 2008, 03:51:5727. 6. 08
do


Hi.

The excerpt from the man says:

> When an interactive shell that is not a login shell is
> started, bash reads and executes commands from ~/.bashrc, if
> that file exists. This may be inhibited by using the --norc
> option. The --rcfile file option will force bash to read
> and execute commands from file instead of ~/.bashrc.

If i've read right, this is an interactive login shell that you're
starting, ergo .bashrc isn't used. Put all your env settings
in .bash_profile and it should work.

Ricky

neprebran,
27. jun. 2008, 05:23:5327. 6. 08
do
machine:{root}:/ $ su - orausr
machine:{orausr}:~>ln -s .bashrc .bash_profile
machine:{orausr}:~>exit
machine:{root}:/ $ su - orausr -c "env"

HZ=
SHELL=/bin/bash
TERM=xterm
MAIL=/var/mail/orausr
PATH=/usr/bin:
PWD=/oracle/BLAAAA/app/oracle/product/10gr2
LANG=C
TZ=Europe/Rome
SHLVL=1
HOME=/oracle/BLAAAAA/app/oracle/product/10gr2
LOGNAME=orausr
_=/usr/bin/env
macihne:{root}:/ $

As you see, is still not working!
Thanx
Ricky


0 novih sporočil