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

Re: Bash-SU Question

El dom, 14-09-2008 a las 12:53 +1000, Alex Samad escribió:
> 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)

For future reference, it is usually convenient to use single quotes when
using 'su -c'. In OP's case it would look something like:
# su -m -c 'echo User: $(whoami)' user1

That way you won't have to care about escaping.


Gabriel Parrondo
GNU/Linux User #404138
GnuPG Public Key ID: BED7BF43
JID: gabrielp@xmpp.us

"The only difference between theory and practice is that, in theory,
there's no difference between theory and practice."

Attachment: signature.asc
Description: Esta parte del mensaje =?ISO-8859-1?Q?est=E1?= firmada digitalmente

Reply to: