What is causing this script to exit the loop at line "program is exiting loop here"? In the context it will loop twice but it won't if i have the CM_CHECK_STATUS where i have it.
RUNLOG="log"
OUTPUTFILE="output"
LIST=$(/usr/local/bin/sshpass -f $PASSWORD_FILE ssh -o StrictHostKeyChecking=no $USER@$IP "ls -al" 2>> $RUNLOG > $OUTPUTFILE)
PS_VALS=$(cat $OUTPUTFILE)
if [[ $? != 0 ]]
then
echo "There was an error at:" `date` >> $RUNLOG
else
while IFS= read -r line;
do
# Check ls
echo "... $line ..."
CM_CHECK_STATUS=$(/usr/local/bin/sshpass -f $PASSWORD_FILE ssh -o StrictHostKeyChecking=no $USER@$IP "ls -al")
#program is exiting loop here
done <<< "$PS_VALS"
echo "finished"
fi
If i remove CM_CHECK_STATUS=$(/usr/local/bin/sshpass -f $PASSWORD_FILE ssh -o StrictHostKeyChecking=no $USER@$IP "ls -al") and place it anywhere else outside the loop that command works fine and the loop runs as expected. Is there something wrong with using that command inside a loop?