From owner-freebsd-questions@FreeBSD.ORG Mon Jul 25 14:10:17 2005 Return-Path: X-Original-To: questions@freebsd.org Delivered-To: freebsd-questions@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5ECC216A41F for ; Mon, 25 Jul 2005 14:10:17 +0000 (GMT) (envelope-from garys@opusnet.com) Received: from opusnet.com (mail.opusnet.com [209.210.200.6]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9858043D45 for ; Mon, 25 Jul 2005 14:10:16 +0000 (GMT) (envelope-from garys@opusnet.com) Received: from localhost.localhost [70.98.247.55] by opusnet.com with ESMTP (SMTPD32-8.05) id A29D2C380110; Mon, 25 Jul 2005 07:09:33 -0700 Received: from localhost.localhost (localhost.localhost [127.0.0.1]) by localhost.localhost (8.13.3/8.13.3) with ESMTP id j6PEArjS008784; Mon, 25 Jul 2005 07:10:53 -0700 (PDT) (envelope-from garys@opusnet.com) Received: (from jojo@localhost) by localhost.localhost (8.13.3/8.13.3/Submit) id j6PEAloq008783; Mon, 25 Jul 2005 07:10:47 -0700 (PDT) (envelope-from garys@opusnet.com) To: Damian Gerow References: <20050725003238.GD2461@afflictions.org> <20050725100902.GI2461@afflictions.org> From: garys@opusnet.com (Gary W. Swearingen) Date: Mon, 25 Jul 2005 07:10:47 -0700 In-Reply-To: <20050725100902.GI2461@afflictions.org> (Damian Gerow's message of "Mon, 25 Jul 2005 06:09:02 -0400") Message-ID: <7vy87vkmc8.87v@mail.opusnet.com> User-Agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Jumbo Shrimp, berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-RBL-Warning: WEIGHT10: Total weight between 10 and 14. X-Spam-Tests-Failed: SPAMDOMAINS, SPFf, WEIGHT10 [11] Cc: questions@freebsd.org, "Gary W. Swearingen" Subject: Re: Shell scripts, SSH sessions, and for loops, oh my! X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Jul 2005 14:10:17 -0000 Damian Gerow 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