Mail Archives: cygwin/2006/08/04/11:05:49
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 -