From owner-freebsd-questions@FreeBSD.ORG Mon Jul 25 05:47:47 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 C5B4116A420 for ; Mon, 25 Jul 2005 05:47:47 +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 2706A43D5E for ; Mon, 25 Jul 2005 05:47:47 +0000 (GMT) (envelope-from garys@opusnet.com) Received: from localhost.localhost [70.98.247.55] by opusnet.com with ESMTP (SMTPD32-8.05) id AD022A4A00A2; Sun, 24 Jul 2005 22:47:46 -0700 Received: from localhost.localhost (localhost.localhost [127.0.0.1]) by localhost.localhost (8.13.3/8.13.3) with ESMTP id j6P5mLhe001265; Sun, 24 Jul 2005 22:48:21 -0700 (PDT) (envelope-from garys@opusnet.com) Received: (from jojo@localhost) by localhost.localhost (8.13.3/8.13.3/Submit) id j6P5mGHc001264; Sun, 24 Jul 2005 22:48:16 -0700 (PDT) (envelope-from garys@opusnet.com) To: Damian Gerow References: <20050725003238.GD2461@afflictions.org> From: garys@opusnet.com (Gary W. Swearingen) Date: Sun, 24 Jul 2005 22:48:16 -0700 In-Reply-To: <20050725003238.GD2461@afflictions.org> (Damian Gerow's message of "Sun, 24 Jul 2005 20:32:38 -0400") Message-ID: 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 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 List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Jul 2005 05:47:47 -0000 Damian Gerow writes: > 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 Here's a few clues (assuming you really want the single quotes in there): echo "THIS is SHELL: '\$SHELL'" echo "THIS is SHELL: '"'$SHELL'"'" echo 'THIS is SHELL: '\''$SHELL'\' which all give THIS is SHELL: '$SHELL'