X-Spam-Check-By: sourceware.org
Date: Mon, 14 Aug 2006 22:55:23 +0300
Message-Id: <200608141955.k7EJtNiE014364@beta.mvs.co.il>
From: "Ehud Karni" <ehud@unix.mvs.co.il>
To: knellis@syntek-usa.com, cbrown13800@hotmail.com
Cc: cygwin@cygwin.com
Subject: Re: ssh breaks while loop
In-reply-to: <017301c6bfa9$25180ff0$9d32000a@idirect.net> (message from 	Kenneth Nellis on Mon, 14 Aug 2006 09:54:21 -0400)
Reply-to: ehud@unix.mvs.co.il
References:  <017301c6bfa9$25180ff0$9d32000a@idirect.net>
X-Mailer: Emacs 21.3.1 rmail (send-msg 1.108)
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-8-i
Content-Transfer-Encoding: 7bit
X-IsSubscribed: yes
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
Precedence: bulk
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie.com@cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com

On Mon, 14 Aug 2006 09:54:21 -0400, Kenneth Nellis wrote:
>
> FWIW, I see the same behavior, but not just Cygwin, but also on
> a Red Hat Linux installation, so I guess it's more of a bash/ssh
> issue than one with Cygwin.

There are 2 issues here, One is ssh's, the other is with sh/bash.
None is Cygwin specific, i.e. it is OFFTOPIC.

On Friday, August 04, 2006 10:01 AM, BC wrote:
BC> If file hostlist contains:
BC> hosta
BC> hostb
BC> hostc
BC>
BC> then execute this shell script:
BC> while read host
BC> do
BC>     ssh $host ls -al .profile
BC> done < hostlist
BC>
BC> the while loop executes one time and quits.

The problem is that `ssh' read stdin. To overcome this change it to:
        ssh $host ls -al .profile < /dev/null

A second possible problem is that ssh may exit with error, the
solution is to add  set +e  (in separate line) before the ssh line.

Ehud.


--
 Ehud Karni           Tel: +972-3-7966-561  /"\
 Mivtach - Simon      Fax: +972-3-7966-667  \ /  ASCII Ribbon Campaign
 Insurance agencies   (USA) voice mail and   X   Against   HTML   Mail
 http://www.mvs.co.il  FAX:  1-815-5509341  / \
 GnuPG: 98EA398D <http://www.keyserver.net/>    Better Safe Than Sorry

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

