0

This script should call ls on the remote host N times, where N is the number of lines in the file file-name. For some reason it always runs once and then exits. If I change f to do something else (print a number, print the line of the file, etc) it works as expected and f is called N times. When I'm using ssh to execute a remote command, it only runs once. I did notice that changing the loop to no longer read input from the file seems to fix the issue, but I'd like to try and fix it a different way (I need to read the file).

function f() {
    ssh -i key user@host ls
}

while read line; do
  f
done<file-name
Bryant
  • 3,011
  • 1
  • 18
  • 26

0 Answers0