I write a deployAll.sh, which read ip_host.list line by line, then add group for all the remote hosts,
when I run: sh deployAll.sh
results:
Gro
Without the ssh
command (which wouldn't make sense on my network), I get the expected output so I suspect that the ssh
command is swallowing the remaining standard input. You should use the -n
flag to prevent ssh
from reading from stdin
(equivalent to redirecting stdin
from /dev/null
):
ssh -n "${ipandhost[0]}" "groupadd -g 1011 test"
or
ssh "${ipandhost[0]}" "groupadd -g 1011 test" < /dev/null
See also How to keep script from swallowing all of stdin?