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!!
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 ofcat reservations | while read LINE; do ... done
you can usewhile read LINE; do ... done < reservations
– Bodo May 21 '19 at 09:07set -e
. The simplified version reproduces. I tried the<reservations
thing but it didn't help – fabian789 May 21 '19 at 09:09ssh -v
(morev
's (up to 3) for even more verbosity) – Httqm May 21 '19 at 09:20