Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 25 Jul 2005 07:10:47 -0700
From:      garys@opusnet.com (Gary W. Swearingen)
To:        Damian Gerow <dgerow@afflictions.org>
Cc:        questions@freebsd.org, "Gary W. Swearingen" <garys@opusnet.com>
Subject:   Re: Shell scripts, SSH sessions, and for loops, oh my!
Message-ID:  <7vy87vkmc8.87v@mail.opusnet.com>
In-Reply-To: <20050725100902.GI2461@afflictions.org> (Damian Gerow's message of "Mon, 25 Jul 2005 06:09:02 -0400")
References:  <20050725003238.GD2461@afflictions.org> <q33bq3mo67.bq3@mail.opusnet.com> <20050725100902.GI2461@afflictions.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Damian Gerow <dgerow@afflictions.org> writes:

> Yeah, but...
>
> The current shell still interprets $SHELL, and assigns it whatever local
> value it has.  I don't want that.  I want $SHELL to be evaluated by the
> remote system (the on to which I am establishing the SSH connection).

No, the whole object of my examples was to pass "$SHELL" to the echo
command without interpretation by the shell -- which they did.
>
> To answer my own question: it looks like sh just isn't the right tool for
> the job.  I'm going to have to either completely change my approach to the
> problem I'm trying to solve, or use Perl and Net::SSH (and given my problem,
> I'm tending towards the latter).

Standard shells can do almost anything; just awkwardly and in
hard-to-decipher style.

This should demonstrate better.  I've got two scripts:

-- tryit:
#!/bin/sh
PROCESS=process
export PROCESS
ssh "for PROCESS in 01 02 ; do echo \${PROCESS} ; done"

-- ssh:
#!/bin/sh
PROCESS=newproc
echo "From 'ssh': '$@'"
eval "$@"

-- running tryit:
$ temptry
>From 'ssh': 'for PROCESS in 01 02 ; do echo ${PROCESS} ; done'
01
02



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?7vy87vkmc8.87v>