http://www.perlmonks.org?node_id=571348


in reply to Re: Testing for port connectivity
in thread Testing for port connectivity

As brd said, nmap does that and much more, if that is a tool which is available to you. If you aren't familiar with nmap, it will write output files in several different formats, including:
  • normal (-oN)
  • XML (-oX)
  • "s|<rIpt kIddi3" (-oS)
  • grepable format (-oG)