This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: ssh breaks while loop


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@cs.nyu.edu | igor@watson.ibm.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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]