bug-sh-utils
[Top][All Lists]
Advanced

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

Re: swith user to a bash user


From: Bob Proulx
Subject: Re: swith user to a bash user
Date: Mon, 6 Oct 2003 10:37:01 -0600
User-agent: Mutt/1.3.28i

Nicola Lodato wrote:
> I've a user /test /that has a /bin/bash shell. In his .profile file 
> there is these lines:
> ODSRELEASE=/some/dir/
> export ODSRELEASE
> 
> When, as user root, I try this command:
> 
> su - test -c "echo $ODSRELEASE"

You are getting confused about shell command line quoting.  The
$ODSRELEASE is getting expanded by *your* shell inside the double
quotes and the sub-shell is never even getting the query.  It is only
seeing an empty echo command.

Try this instead.

  su - test -c 'echo $ODSRELEASE'

or

  su - test -c "echo \$ODSRELEASE"

Use 'echo' again to see what the expansion of the command line looks
like.

  echo su - test -c "echo $ODSRELEASE"
  echo su - test -c 'echo $ODSRELEASE'
  echo su - test -c "echo \$ODSRELEASE"

Bob




reply via email to

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