You are not logged in.

#1 2003-12-02 17:50:41

chane
Member
Registered: 2003-12-02
Posts: 93

su setup of environment variables

During the initialization of my system, I have written a script (loaded in the modules section of rc.conf) that starts up an application.  I want to run this application as a specific user.  So in my startup script I issue:

  su - username -c "start command"

When I user other distros and the man pages say that when I use the form "su -" that the current environment should be passed to the new shell (with a modification to the path).  However, after a bit of fidling around I have determined that none of the enviroment is passed.

Before I issue the su command, I export several variables that the program looks for in order to run.  These are not being copied to the new shell.

Is there a way to have a su'ed shell to have the same enviornment as it's "parent"?  Any other ideas on how to start to application as another user (non-root)?

Thanks for your help,
Chris....

Offline

#2 2003-12-02 18:18:32

andy
Member
From: Germany
Registered: 2002-10-11
Posts: 374

Re: su setup of environment variables

it seems you confused the terms ;-) ... you actually have to use su without the "-" ...

With environment the docs mean the user environemnt of the user you are su-ing to. I.e. if you do
su - user
you will get the environment of user as if he logged in - everything else wiped. With
su user
you will only become user keeping the current environment.

Offline

#3 2003-12-02 18:34:07

chane
Member
Registered: 2003-12-02
Posts: 93

Re: su setup of environment variables

doh!  thanks for the help.

Chris....

Offline

Board footer

Powered by FluxBB