From owner-freebsd-questions@FreeBSD.ORG Sat Jul 30 05:24:08 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 15E1C16A41F for ; Sat, 30 Jul 2005 05:24:08 +0000 (GMT) (envelope-from larsen.nick@gmail.com) Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.198]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9F7C543D46 for ; Sat, 30 Jul 2005 05:24:07 +0000 (GMT) (envelope-from larsen.nick@gmail.com) Received: by zproxy.gmail.com with SMTP id z6so500471nzd for ; Fri, 29 Jul 2005 22:24:07 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=HNoSUkfiFRK/9EBE2Jr5M0ULCJY4hSPXi68Fkpaku0/G2WieGGt+4ee/kY4TiLBSk/Z4VfxX3DleZK6Y0eS0KR9gJNSADaRFcsW52oMO8nphSK+iXr20UbewLzCFGUg+hMP92O1zb+/5qsLhy18+O9m06fWJkeaTwO/ybb8PwcQ= Received: by 10.37.22.3 with SMTP id z3mr3354029nzi; Fri, 29 Jul 2005 22:24:07 -0700 (PDT) Received: by 10.36.103.9 with HTTP; Fri, 29 Jul 2005 22:24:04 -0700 (PDT) Message-ID: Date: Sat, 30 Jul 2005 17:24:04 +1200 From: Nick Larsen To: Damian Gerow In-Reply-To: <20050725003238.GD2461@afflictions.org> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <20050725003238.GD2461@afflictions.org> Cc: questions@freebsd.org 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 Reply-To: Nick Larsen List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 30 Jul 2005 05:24:08 -0000 Hi, You need to escape the metacharacters, so $ will be \$. Double quotes expand variables, single quotes do not, sou cou could just put it all in single quotes. The local system will see the $ as a literal, but the remote system will see it as a variable. Hope this helps some. Nick Larsen ( http://datanet.co.nz/ ) On 7/25/05, Damian Gerow wrote: > (I don't really know /where/ to ask this question. It's not particularly > FreeBSD-centric, but the list has been good to me in the past, so hopeful= ly > nobody minds.) >=20 > I'm trying to write a shell script that runs a for loop in an SSH session= . > Simply, I'm trying to do this: >=20 > for HOST in `cat hostnames` ; do > ssh ${HOST} "for PROCESS in 01 02 ; do echo '${PROCESS}' ; done" > done >=20 > But because this is run in a script, that gets translated to: >=20 > for HOST in `cat hostnames` ; do > ssh ${HOST} "for PROCESS in 01 02 ; do echo '' ; done" > done >=20 > Which most definitely is not what I want. >=20 > I know a few ways around this -- expand the for loop, have a secondary > script, create a secondary script on-the-fly, etc. -- but I'm curious to = see > if I can convince sh to *not* interpret ${PROCESS}. I've tried escaping = it, > I've tried a double-dollar, and I've tried escaping the double-dollar: no= ne > have worked. >=20 > Does anyone have any ideas? >=20 > - Damian >=20 > P.S. Please reply privately as well to the list; thanks. > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.o= rg" >