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

Re: something strange with rsh/ssh + bash/tcsh is happening. Please advise



On Wed, Dec 28, 2005 at 01:03:09PM -0500, Yaroslav Halchenko wrote:

||  Please advise since I am not sure against which package to file a bug.
||  First I mentioned weird behavior with hostname and filed a bug against
||  it (look below in the quotes). Apparently it might be not a bug of
||  hostname at all...  There is something else weird is happening
||
||  *> rsh node19 '/bin/echo 1111; /bin/echo 123'
||  1111
||  123
||  > rsh node19 /bin/sh -c '/bin/echo 1111; /bin/echo 123'
||
||  123
||  *> rsh node19 /bin/tcsh -c '/bin/echo 1111; /bin/echo 123'
||
||  123
||  *> ssh node19 /bin/tcsh -c '/bin/echo 1111; /bin/echo 123'
||
||  123

It's not a bug. It's a feature. :)

The arguments to rsh/ssh are concatenated with spaces and passed to your
login shell (say $SHELL) with the -c argument. So it runs:

    $SHELL -c '/bin/echo 1111; bin/echo 123'
    $SHELL -c '/bin/sh -c /bin/echo 1111; /bin/echo 123'
    $SHELL -c '/bin/tcsh -c /bin/echo 1111; /bin/echo 123'
    $SHELL -c '/bin/tcsh -c /bin/echo 1111; /bin/echo 123'

The inner shell sees arguments (quoted for clarity):

    /bin/sh   -c '/bin/echo' '1111'
    /bin/tcsh -c '/bin/echo' '1111'
    /bin/tcsh -c '/bin/echo' '1111'

So it runs the command /bin/echo with $1=1111.  However, /bin/echo
doesn't use $1, and only prints an empty line which you see.

After that, the login shell runs /bin/echo 123, which prints 123 as
you see.

Ciao. Vincent.
-- 
Vincent Zweije <zweije@xs4all.nl>    | "If you're flamed in a group you
<http://www.xs4all.nl/~zweije/>      | don't read, does anybody get burnt?"
[Xhost should be taken out and shot] |            -- Paul Tomblin on a.s.r.

Attachment: signature.asc
Description: Digital signature


Reply to: