I'm looking for some help in figuring why my little bit of code will not process any entries other then the first one in my list.
while read line ;do
hostname=${line//\"}
a=`ssh user@$hostname uptime;echo $?`
if [[ "$a" = "255" ]];then
dt=`date`
touch /home/user/email.txt
echo "To:user@userdomain.com" >> /home/user/email.txt
echo "Subject: URGENT - $hostname is down" >> /home/user/email.txt
echo "Content-Type: text/plain" >> /home/user/email.txt
echo "X-Priority: 1 (Highest)" >> /home/user/email.txt
echo "X-MSMail-Priority: High" >> /home/user/email.txt
echo "Connection Failed at: $dt" >> /home/user/email.txt
/usr/sbin/sendmail -t < /home/user/email.txt
rm -f /home/user/email.txt
fi
rm -f /home/user/email.txt
done < "/home/user/servers.txt"
It connects to the first server in the list just fine, but will not try the 2nd or 3rd entry in the servers list.