1

I have a really confusing error, in the following script. reservations is just a file with 100 lines, let's say something like this:

apple
pear
fruit
...
cat reservations | while read LINE;
do
  echo $LINE
  for i in {0..2}; do
    ssh -o ConnectTimeout=10 admin@render rm -rf /tmp/lock$i
    echo $i
  done
done

(This is already a simplified version of a production script.)

Now, what I would have expected, is to see an output like this:

apple
0
1
2
pear
0
1
2
...

BUT, I only get the first line, i.e., the output is

apple
0
1
2

If I remove the ssh, everything works! For some reason, the ssh messes up the whole thing, and exits the while loop. I have absolutely no idea why that is!!

fabian789
  • 217
  • 1
    Does it really exit the while loop or does it exit the whole script? Or maybe does the script hang? Do you have set -e somewhere in your script? Can you reproduce the problem with the simplified script? Or did you manually "convert" your real script and its output to the simplified version? BTW: Instead of cat reservations | while read LINE; do ... done you can use while read LINE; do ... done < reservations – Bodo May 21 '19 at 09:07
  • @Bodo What's shown above is the whole script, I have no set -e. The simplified version reproduces. I tried the <reservations thing but it didn't help – fabian789 May 21 '19 at 09:09
  • Can you have further details on your ssh command with increased verbosity : ssh -v (more v's (up to 3) for even more verbosity) – Httqm May 21 '19 at 09:20
  • 1
    this question solves it. Should I remove my question? Thing is, googling didn't help because there is no "kill" there. – fabian789 May 21 '19 at 09:22
  • Hi, next time you should add above comment as answer and mark it as a solving answer. I almost miss this little comments :) .. thanks for thinking like me when state an issue haha "kills" – Maverick.pe Apr 29 '20 at 18:52

0 Answers0