I have 100 servers and i need to login to them with ssh from central server using script: i tried below with this i should get the version redirected to the file which will be stored at central server.
#!/bin/bash
CMD='java -version'
while read line
do
ssh -n user@"$line" $CMD >> /pathforoutputfile/outputjava.txt
done < /pathforhosts/hosts.txt
But I am not getting output generated in file /pathforoutputfile/outputjava.txt
ansiblefor server orchestration. see stackoverflow.com/questions/30388361/…set -x.