From owner-freebsd-questions@FreeBSD.ORG Mon Jul 25 00:32:49 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 1A3B616A41F for ; Mon, 25 Jul 2005 00:32:49 +0000 (GMT) (envelope-from dgerow@afflictions.org) Received: from pandora.afflictions.org (asylum.afflictions.org [64.7.134.90]) by mx1.FreeBSD.org (Postfix) with ESMTP id A581443D45 for ; Mon, 25 Jul 2005 00:32:48 +0000 (GMT) (envelope-from dgerow@afflictions.org) Received: from localhost (localhost [127.0.0.1]) by pandora.afflictions.org (Postfix) with ESMTP id B030D78C75 for ; Sun, 24 Jul 2005 20:36:00 -0400 (EDT) Received: from pandora.afflictions.org ([127.0.0.1]) by localhost (pandora.afflictions.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 30430-06 for ; Sun, 24 Jul 2005 20:35:53 -0400 (EDT) Received: from dementia.afflictions.org (dementia.afflictions.org [172.19.206.56]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by pandora.afflictions.org (Postfix) with ESMTP id CDE5778C72 for ; Sun, 24 Jul 2005 20:35:52 -0400 (EDT) Received: by dementia.afflictions.org (Postfix, from userid 1001) id B244E33C64; Sun, 24 Jul 2005 20:32:38 -0400 (EDT) Date: Sun, 24 Jul 2005 20:32:38 -0400 From: Damian Gerow To: questions@freebsd.org Message-ID: <20050725003238.GD2461@afflictions.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-GPG-Fingerprint: B3D7 D901 A53A 1A99 BFD6 E6DF 9F3B 742B C288 9CC9 User-Agent: Mutt/1.5.9i X-Virus-Scanned: amavisd-new at pandora.afflictions.org Cc: Subject: 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 00:32:49 -0000 (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 hopefully nobody minds.) I'm trying to write a shell script that runs a for loop in an SSH session. Simply, I'm trying to do this: for HOST in `cat hostnames` ; do ssh ${HOST} "for PROCESS in 01 02 ; do echo '${PROCESS}' ; done" done But because this is run in a script, that gets translated to: for HOST in `cat hostnames` ; do ssh ${HOST} "for PROCESS in 01 02 ; do echo '' ; done" done Which most definitely is not what I want. 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: none have worked. Does anyone have any ideas? - Damian P.S. Please reply privately as well to the list; thanks.