You are not logged in.

#1 2012-04-01 12:22:02

lbacelar
Member
Registered: 2012-04-01
Posts: 2

~/.profile no being sourced when using 'su -l -c "..."

Hello all,

First of all, i might be posting this on the wrong place, so if that's the case, sorry about that  ... It's my first post here.

I have a script to run that at some given point executes a command in another user's space. I am issuing

su -l -c "some command" user

The problem is that the command I am running depends on environment variables that are set on ~user/.profile. (NOTE: I have no .bash_profile on ~user)

What I expected according to the man pages was that su sourced the ~/.profile, but that is clearly not happening. I tried with .bash_profile or /etc/profile with the same result.

This just happens when i do

'su -l -c'

If I do just

su -l

the  /.profile is sourced correctly, but this does not help me during the script.

Right now i am thinking this might be something Arch related, since I have done this on other distros with no problems.


Can anyone help me ?

Tanx,

Offline

#2 2012-04-01 12:26:36

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,561
Website

Re: ~/.profile no being sourced when using 'su -l -c "..."

you could try

su -l -c '/bin/bash -i -c "some command"' user

as su does not seem to have the -i flag.

Last edited by Trilby (2012-04-01 12:26:54)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3 2012-04-01 12:31:49

lbacelar
Member
Registered: 2012-04-01
Posts: 2

Re: ~/.profile no being sourced when using 'su -l -c "..."

Nope, sorry ...

Still the same. No ~/.profile sourced.
The -l (or just -) option on su ought to do it ... it invokes a login shell which should source /etc/profile and .bash_profile or .profile, whichever is present.

Tanx anyway ...

Offline

Board footer

Powered by FluxBB