FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Debian > Debian User

 
 
LinkBack Thread Tools
 
Old 07-08-2010, 09:27 AM
Sthu Deus
 
Default su and environment.

Good day.

The following:

$ su -c 'abc' -l anotheruser

but it returns

-su: abc: command not found

The abc is in the anotheruser's path, but it seems option '-l' does not
work here.

How I can accomplish the goal (without manually specifying complete
path)?


Thank You for Your time.


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 4c359a04.487e0e0a.4c8c.7106@mx.google.com">http://lists.debian.org/4c359a04.487e0e0a.4c8c.7106@mx.google.com
 
Old 07-08-2010, 11:46 PM
Bob McGowan
 
Default su and environment.

On 07/08/2010 02:27 AM, Sthu Deus wrote:
> Good day.
>
> The following:
>
> $ su -c 'abc' -l anotheruser
>
> but it returns
>
> -su: abc: command not found
>
> The abc is in the anotheruser's path, but it seems option '-l' does not
> work here.
>
> How I can accomplish the goal (without manually specifying complete
> path)?
>
>
> Thank You for Your time.

The above command line worked for me. What system are you using, which
shell?

Is this other user's path really getting set? Is 'abc' executable and
is the content runable (in other words, if it's a script and it begins
with '#!/bin/bash', is bash really in /bin, or if it's binary, is the
binary runable for the system you're on)?

You might want to try using the 'echo' or 'env' commands to validate the
environment variables PATH and HOME. You may also want to try running a
normal system command such as 'date', to see if that works.

Good luck.

--
Bob McGowan


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 4C366356.6080708@symantec.com">http://lists.debian.org/4C366356.6080708@symantec.com
 
Old 07-09-2010, 03:57 PM
Bob Proulx
 
Default su and environment.

Sthu Deus wrote:
> $ su -c 'abc' -l anotheruser
> -su: abc: command not found
>
> The abc is in the anotheruser's path, but it seems option '-l' does not
> work here.

A very confusing topic and one often discussed is the process bash
uses to start up and what environment files are processed and at what
times. PATH is usually set in a user's .profile (or .bash_profile).
The .bashrc is not loaded at login time and is usually sourced from
the .profile.

If a user has added PATH to .bashrc and hasn't sourced the .bashrc in
the .profile then something like the above can occur. But that isn't
a "correct" configuration IMNHO.

Try this to print the PATH:

su -l anotheruser -c 'printenv PATH'

> How I can accomplish the goal (without manually specifying complete
> path)?

Put PATH setup in the .profile (or .bash_profile) and source the
.bashrc from the .profile.

If modifying the other user environment is not possible then you would
need to source the files expliclitly.

su anotheruser -c '. ~/.bashrc ; printenv PATH'

Bob
 
Old 07-10-2010, 08:07 AM
Sthu Deus
 
Default su and environment.

Thank You for Your time and answer, Bob:

> > $ su -c 'abc' -l anotheruser
> >
> > but it returns
> >
> > -su: abc: command not found
> >
> > The abc is in the anotheruser's path, but it seems option '-l' does
> > not work here.
> >
> > How I can accomplish the goal (without manually specifying complete
> > path)?
> >
> The above command line worked for me. What system are you using,
> which shell?

I do believe You - recently I had another strange experience and again
w/ bash's 'if' construction like this:

if [ "$a" == --help ]

- in one Debian 5 it worked, another - not!

I use Debian 5 mixture of stable and testing - all updated up-to-day.

Both users use

/bin/bash

version 3.2-4.

> Is this other user's path really getting set? Is 'abc' executable and

No. And here the question arises, Why? As I do understand the su
manual. it says that option '-l' helps to load his (another_user's ENV).

> is the content runable (in other words, if it's a script and it begins
> with '#!/bin/bash', is bash really in /bin, or if it's binary, is the
> binary runable for the system you're on)?

Yes, it is executable - it runs just fine if I do:

su - another_user

and then in its shell run the

abc

w/o specifying the path and the abc is not in CWD.


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 4c382a9b.ce7c0e0a.180f.4934@mx.google.com">http://lists.debian.org/4c382a9b.ce7c0e0a.180f.4934@mx.google.com
 

Thread Tools




All times are GMT. The time now is 09:41 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org