delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2006/08/04/11:05:49

X-Spam-Check-By: sourceware.org
Date: Fri, 4 Aug 2006 11:05:36 -0400 (EDT)
From: Igor Peshansky <pechtcha AT cs DOT nyu DOT edu>
Reply-To: cygwin AT cygwin DOT com
To: CB <cbrown13800 AT hotmail DOT com>
cc: cygwin AT cygwin DOT com
Subject: Re: ssh breaks while loop
Message-ID: <Pine.GSO.4.63.0608041101250.17434@access1.cims.nyu.edu>
MIME-Version: 1.0
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

On Fri, 4 Aug 2006, CB wrote:

> If file hostlist contains:
> hosta
> hostb
> hostc
>
> then execute this shell script:
> while read host
> do
>     ssh $host ls -al .profile
> done < hostlist
>
> the while loop executes one time and quits.
>
> But,
> while read host
> do
>     echo $host
> done < hostlist
>
> executes 3 times.
>
> Am I missing something or is this a bug?

WJFFM.  There are many things that can be different in our environments.
Are you sure you're reading the hosts separately?  What's IFS set to?
Try prepending something to $host in your second loop, e.g., "echo Host:
$host" and see if you get them echoed one host at a time, or all three at
once.  You may also insert "echo" before the ssh in the first loop and see
if you get 3 echoes.  Also, is "set -e" in effect?  If it is, the loop may
be quitting if the first ssh returns false.
	Igor
-- 
				http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_	    pechtcha AT cs DOT nyu DOT edu | igor AT watson DOT ibm DOT com
ZZZzz /,`.-'`'    -.  ;-;;,_		Igor Peshansky, Ph.D. (name changed!)
     |,4-  ) )-,_. ,\ (  `'-'		old name: Igor Pechtchanski
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

"Las! je suis sot... -Mais non, tu ne l'es pas, puisque tu t'en rends compte."
"But no -- you are no fool; you call yourself a fool, there's proof enough in
that!" -- Rostand, "Cyrano de Bergerac"

--
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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019