Script to locating Linux servers

All,
Need an urgent help! ,
I have an simple text file that holding more than 500 IP Address,

My requirement :
bash script that will run from my central server , and will scan with nmap all the 500 ip address , for ssh port with . for example with the command : nmap -sT | grep '22.*open'

After the scan, I want him to transfer output of any address he found that SSH port is open to another text file.

What will be the effective script?

Note, I do not want him to run on subnet, only on all the ip address that found on the file.

Thank you.

Quick reply

while read line
do
echo $line
Parse the line to get the IPaddress
<run nmap command for checking the >
done <"IP-Adress-File"

"The --data-length option can be used to send a fixed-length random payload to every port. If an ICMP port unreachable error (type 3, code 3) is returned, the port is closed."
Check first nmap works this way.