markus.sonderegger@juliusbaer.com wrote:
> root@ws0054:/# /bin/su - bcom -c "id"
> uid=120(bcom) gid=129(bcom)
>
> As one can see from the last line .profile gets not executed.
See the INVOCATION section of the man page:
An interactive shell is one started without non-option
arguments and without the -c option whose standard input
and output are both connected to terminals (as determined
by isatty(3)), or one started with the -i option.
...
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.
Your shell is non-interactive (due to -c) and does not have --login,
so it doesn't read the *profile files.
paul