I'm using following shell script to check through set of ip and port from csv file. But it always breaking the while loop and only show the first result. But any how without error the script reaches the last line also. How to fix the loop breaking issue in telnet?
echo "starts"
while read p; do
if [ ! -z "$p" -a "$p" != " " ]; then
IP=`echo $p | cut -d',' -f1`
PORT=`echo $p | cut -d',' -f2`
TELNET_STR=`telnet "$IP" "$PORT" | grep "Connected"`
if [ ! -z "$TELNET_STR" -a "$TELNET_STR" != " " ]; then
echo '[success]:'$IP':'$PORT
else
echo '[failed]:'$IP':'$PORT
fi
fi
done <telnet.csv
echo "ends"
telnet.csv
234.253.245.23,80,1
234.089.108.216,8080,1
234.23.23.216,21,1