Submitted 24-Jun-00 by Jasper Spit:
> Hi,
> 
> On Mandrake 7.0 when you do a su - <user> -c "command" from the root
> account, <user>'s profile is not loaded. When you just do a su -
> <user>, it works OK.

This is correct behavior.  su - <user> is a login shell, which is the
only time <user>'s profile is loaded.  su -c only executes a command
as if it were that user.

> This is very annoying, I need to create a script that runs as root
> and executes some commands as another user. I can't get this to work
> right now.
> Even su - <user> -c ". .profile; echo $ORACLE_HOME" doesn't work.

Those are conflicting options. A shell cannot be both a login shell
and only be passed the single command.  Also you're attemting to
source .profile from $PWD.  if $PWD is not <user>'s $HOME then you
aren't sourcing the correct file.

> How can I get this fixed ? I can't remember having this problem on
> Red Hat or SuSE. I upgraded to the newest sh-utils, but that didn't
> help either.

How about su -c ". ~user/.profile;echo $ORACLE_HOME"

-- 
       _
     _|_|_
      ( )   *    Anton Graham
      /v\  /     <[EMAIL PROTECTED]>
    /(   )X
     (m_m)       GPG ID: 18F78541
Penguin Powered!

Reply via email to