title: Bash script telnet to test multiple addresses and ports
body: <p>I am required to test at least 130 ip addresses and ports.
  I am hoping to write a bash script such that it reads the ip address and ports from an input file.</p>
  
  <p>I have the following</p>
  
  <pre><code>while read line
  do
  telnet $line &gt;&gt; $2
  done &lt; $1
  </code></pre>
  
  <p>This is a crappy code as it cannot determine whether its connected or failed, and I have to rely on its auto escape character to disconnect from a connection.</p>
  
  <p>How can I improvise this such that it updates $2 with the status quickly?
  I am working on Redhat and do not have netcat or expect installed..</p>