Subject: Re: ssh breaks while loop
From: "Ehud Karni" <[email-masked]>
To: [email-masked], [email-masked]
Cc: [email-masked]
Date: Mon, 14 Aug 2006 22:55:23 +0300

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/