<br>I&#39;m working on a program that telnets to multiple devices to test their backup ISDN BRI connections. I&#39;m trying to build in error recovery with try/except logic, but I&#39;m having trouble getting it to work. This first example uses a host name that isn&#39;t in our DNS (yes, this does happen):
<br><br>&gt;&gt;&gt; import telnetlib<br>&gt;&gt;&gt; host = &quot;s3793ap01&quot;<br>&gt;&gt;&gt; telnetlib.Telnet(host)<br><br>Traceback (most recent call last):<br>&nbsp; File &quot;&lt;pyshell#30&gt;&quot;, line 1, in &lt;module&gt;
<br>&nbsp;&nbsp;&nbsp; telnetlib.Telnet(host)<br>&nbsp; File &quot;c:\python25\lib\telnetlib.py&quot;, line 208, in __init__<br>&nbsp;&nbsp;&nbsp; self.open(host, port)<br>&nbsp; File &quot;c:\python25\lib\telnetlib.py&quot;, line 225, in open<br>&nbsp;&nbsp;&nbsp; for res in 
socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM):<br>gaierror: (11001, &#39;getaddrinfo failed&#39;)<br>&gt;&gt;&gt; <br>&gt;&gt;&gt; <br>&gt;&gt;&gt; <br>&gt;&gt;&gt; <br>&gt;&gt;&gt; try:<br>&nbsp;&nbsp;&nbsp; telnetlib.Telnet(host)
<br>except gaierror, e:<br>&nbsp;&nbsp;&nbsp; print &quot;error found&quot;, e<br><br><br>&nbsp;&nbsp;&nbsp; <br><br>Traceback (most recent call last):<br>&nbsp; File &quot;&lt;pyshell#16&gt;&quot;, line 3, in &lt;module&gt;<br>&nbsp;&nbsp;&nbsp; except gaierror, e:<br>NameError: name &#39;gaierror&#39; is not defined
<br>&gt;&gt;&gt; <br>&gt;&gt;&gt; <br>&gt;&gt;&gt; <br>&gt;&gt;&gt; try:<br>&nbsp;&nbsp;&nbsp; telnetlib.Telnet(host)<br>except IOError, e:<br>&nbsp;&nbsp;&nbsp; print &quot;error found&quot;, e<br><br><br>&nbsp;&nbsp;&nbsp; <br><br>Traceback (most recent call last):
<br>&nbsp; File &quot;&lt;pyshell#22&gt;&quot;, line 2, in &lt;module&gt;<br>&nbsp;&nbsp;&nbsp; telnetlib.Telnet(host)<br>&nbsp; File &quot;c:\python25\lib\telnetlib.py&quot;, line 208, in __init__<br>&nbsp;&nbsp;&nbsp; self.open(host, port)<br>&nbsp; File &quot;c:\python25\lib\telnetlib.py&quot;, line 225, in open
<br>&nbsp;&nbsp;&nbsp; for res in socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM):<br>gaierror: (11001, &#39;getaddrinfo failed&#39;)<br><br><br>As you can see, I&#39;m not sure how to handle the error. Any ideas?<br><br>