This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: ssh breaks while loop
- From: "Ehud Karni" <ehud at unix dot mvs dot co dot il>
- To: knellis at syntek-usa dot com, cbrown13800 at hotmail dot com
- Cc: cygwin at cygwin dot com
- Date: Mon, 14 Aug 2006 22:55:23 +0300
- Subject: Re: ssh breaks while loop
- References: <017301c6bfa9$25180ff0$9d32000a@idirect.net>
- Reply-to: ehud at unix dot mvs dot co dot il
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/