su - <user> $CMD_OPTS_ARG
GNU bash, version 1.14.7(1)
su - GNU sh-utils 1.12
(Debian 1.2.4, going to get room for 1.3.1 soon.)
VAR=<command options arg> ; export VAR
Calling su like this
echo $VAR | su - <user>
gives a "stdin: is not a tty" message but does a fine job.
Calling su in this other way
su - <user> -c $VAR
results in ANYTHING AFTER THE FIRST SPACE CHARACTER to be executed, that
is only <command>.
No problems if I _write_ on the command line what had to be taken from
$VAR:
su - <user> -c <command options arg>
-------------------------- EXAMPLE --------------------------
nick:~/test# ls -l
total 3
-rw-r--r-- 1 root root 20 Sep 10 16:26 file1.cat
-rw-r--r-- 1 root root 30 Sep 10 16:27 file2.cat
-rw-r--r-- 1 root root 46 Sep 10 16:27 file3.cat
nick:~/test# COMMAND='ls -l /root/test' ; export COMMAND
nick:~/test# echo $COMMAND | su - nbern
stdin: is not a ttytotal 3
-rw-r--r-- 1 root root 20 Sep 10 16:26 file1.cat
-rw-r--r-- 1 root root 30 Sep 10 16:27 file2.cat
-rw-r--r-- 1 root root 46 Sep 10 16:27 file3.cat
nick:~/test# su - nbern -c $COMMAND
--cut--
--cut--
<^ Here I get the same as from 'ls' done inside /home/nbern, that is
COMMAND has been truncated to ls; it does not happen if I explicitly copy
the content of $COMMAND to the command line: >
nick:~/test# su - nbern -c 'ls -l /root/test'
total 3
-rw-r--r-- 1 root root 20 Sep 10 16:26 file1.cat
-rw-r--r-- 1 root root 30 Sep 10 16:27 file2.cat
-rw-r--r-- 1 root root 46 Sep 10 16:27 file3.cat
nick:~/test#
-------------------------------------------------------------
Am i missing something?
Cheers.
Nicola Bernardelli <nbern@mail.protos.it>
---------------------------------------------------------------------------
Please use <n.bern@mail.protos.it> for messages from any kind of
robot, such as mailing lists. From that address no autoresponse
messages will return even when I'm not at home.
---------------------------------------------------------------------------
--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word "unsubscribe" to
debian-user-request@lists.debian.org .
Trouble? e-mail to templin@bucknell.edu .
Reply to: