I am writing a script to get the command information of the remote machine usinf while and for loop. PFB the script. But the script ends by giving the single command information only. I have multiple commands in this file (CMDS=$HOMEDIR/cmnd.txt). If I don't use ssh all the commands working fine, but when I use ssh it executes first command only.
#!/bin/bash
HOMEDIR=/home/448130
CMDS=$HOMEDIR/cmnd.txt
while read -r line
do
for i in $(cat hostname.txt);
do
echo "***************************** $line output begins ********************************";
#echo $line
ssh $i $line
echo "***************************** $line output ends ********************************";
done
done < $CMDS
Please help me to fix this.