Weird problem about "while" and "for" cycle statement in ksh
Some day i found a strange phenomenon when i use a loop structure in a ksh script:
(1) using "For" statement:
for i in `cat aaa`
> do
> rsh $i hostname
> done
And it returns the expected value:
P630_4
p630_1
P650_2
(2) using "while" statement:
cat aaa | while read i
> do
> rsh $i hostname
> done
It only returns the first value:
P630_4
it seems that the loop structure does not work when using "while" and there are "rsh" commands in the loop body.
Here supply the content of file aaa:
P630_4
P630_1
P650_2
Any suggestion about this problem ?
Thanks in advance.
Some day i found a strange phenomenon when i use a loop structure in a ksh script:
(1) using "For" statement:
for i in `cat aaa`
> do
> rsh $i hostname
> done
And it returns the expected value:
P630_4
p630_1
P650_2
(2) using "while" statement:
cat aaa | while read i
> do
> rsh $i hostname
> done
It only returns the first value:
P630_4
it seems that the loop structure does not work when using "while" and there are "rsh" commands in the loop body.
Here supply the content of file aaa:
P630_4
P630_1
P650_2
Any suggestion about this problem ?
Thanks in advance.