Hello All,
Can somebody help me with this script. I have an output file with a list of servers ips and ports. I need to be able to run this script to list all the server ips in the outfile and find out if the port is open or not.
#!/bin/sh
IFS=#;for i in $(cat portTest);
do
# check for open ports #
connTest=`echo " " | telnet $i`
if [ "`echo $connTest | awk '{ print $3 }` " = "Connected" ]
then
echo "$connTest port is up"
else
echo "$connTest port is down"
fi
done
The output i am getting now is this
148.xxx.xx.89 44441
148.xxx.xx.92 44441
148.xxx.xx.95 44441
148.xxx.xx.98 44441
148.xxx.xx.101 44441
148.xxx.xx.104 44441
148.xxx.xx.107 44441 port is down
Can somebody pls tell me what i am doing wrong. I've searched the thread and couldn't find anything that is remotely similar. Please note i don't need to specify a username or password.
Thanks for all your help
AC