User Tools

Site Tools


Sidebar

Translations of this page:



最近の更新



Tag Cloud

en:bash:09_while_ssh

09 SSH in While

This will display only one line.

while read NAME HOST CMD
do
  ssh $NAME@$HOST "$CMD"
done

When you run SSH, stdin is directed at it, so the entire file is passed to SSH, not just the one line you read with read. Therefore, after executing SSH, there are no more lines to read, so the while loop will end in one go.

To prevent this, use the -n option to ssh to redirect /dev/null and not redirect stdin.

OK here

while read NAME HOST CMD
do
  ssh -n $NAME@$HOST "$CMD"
done
en/bash/09_while_ssh.txt · Last modified: 2023/07/06 15:29 by matsui