bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: su -l <user> -c "command" fails to honor user's path


From: Brock Noland
Subject: Re: su -l <user> -c "command" fails to honor user's path
Date: Wed, 16 Apr 2008 22:36:05 -0500

On Wed, Apr 16, 2008 at 9:55 PM, Quanah Gibson-Mount <address@hidden> wrote:
>  address@hidden build]# su -l zimbra -c "echo $PATH"
> /usr/kerberos/sbin:/usr/local/java/bin:/usr/local/ant/bin:/usr/local/mysql/bin:/usr/local/ant/bin:/usr/local/java/bin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/home/build/bin:/usr/local/p4/bin
>
>  This means of course, that using "su -l <user> -c command" will fail to
> execute commands that should be found in the user's path, necessitating that
> one use a fully qualified path to the command.

Greetings,

You are using a double quote which will expand the $PATH variable
before switching to the user zimbra. See this example:

address@hidden ~]# su -l noland -c "echo $PATH"
/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
address@hidden ~]# su -l noland -c 'echo $PATH'
/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/noland/bin

Here is another example which shows this:

address@hidden ~]# echo su -l noland -c "echo $PATH"
su -l noland -c echo
/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
address@hidden ~]# echo su -l noland -c 'echo $PATH'
su -l noland -c echo $PATH

Respectfully,
Brock




reply via email to

[Prev in Thread] Current Thread [Next in Thread]