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

Re: Bash-SU Question



On Sat, Sep 13, 2008 at 04:13:27PM -0600, Telly Williams wrote:
> Hi,
> 
> 	Here's my script:
> 
> #!/bin/sh
> 
> su -m -c "echo User: $(whoami)" user1

isn't this $(whoami) being executed in the original /bin/sh to executre
it under the su wouldn't you need something like 

\$(whoami)


> sleep1
> user=$(whoami)
> echo "User: $user"
> 
> 	I expect that when I run this as root, it changes to user1, executes the 
> command specified and outputs to STDOUT "User: user1", and then executes the 
> second command and outputs "User: root".  That's not what's happening.  What happens 
> is that the first echo looks like "User: " and the second looks like "User: root".  
> What am I doing wrong?  Why doesn't whoami output anything after I su to user1?  Thanks.
> 
> -- 
> VR ~
> 	TW
> 	Email: twilliams001@elp.rr.com
> 	"Knowledge Is Power"
> 
> 
> -- 
> To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org 
> with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
> 
> 

-- 
volcano, n.:
	A mountain with hiccups.

Attachment: signature.asc
Description: Digital signature


Reply to: