<div dir="ltr"><div><div><div><div>Ive tried: read_until("Login: "), read_until("User: ") and read_all()  all 3 ways return the same thing: "Welcome to In-Sight(R) 4001 Session 1\r\nUser:" <br>
<br>then I put in: <br><br>tn.write("admin\r\n")<br>or<br>tn.write(USER + "\r\n")<br>or<br>tn.write(USER + "\r") <br></div>or <br></div>tn.write(USER + "\n")<br><br></div>Ive tried every combination I can think of but after that when I put in tn.read_all() I get back ",,," and if I do any type of tn.read_until - it gives me the traceback error.  thanks again for all your input.  really appreciate.<br>
<br></div>Chris<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Feb 25, 2013 at 11:24 AM, square.steve <span dir="ltr"><<a href="mailto:square.steve@gmail.com" target="_blank">square.steve@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div>At the risk of stating the blindingly obvious, have you run a 'real' telnet session to see what  a successful conversation looks like? Might give you some useful pointers for your debug session.</div>
<div><br></div><div>Steve</div><div><br></div><div><br></div><span style="font-size:9px">Sent from a Galaxy far, far away....</span>  <br><br><br>-------- Original message --------<br>From: <a href="mailto:chris.annin@gmail.com" target="_blank">chris.annin@gmail.com</a> <br>
Date:  <br>To: <a href="mailto:python-list@python.org" target="_blank">python-list@python.org</a> <br>Subject: telnet to Cognex In-Sight 4001 camera <br> <br><br>Hello,  ive been struggling with this for a couple weeks now and was hoping someone might be able to help.  I have an older Cognex camera that I need to communicate with via telnet.  I can get a response from the camera when I initiate a telnet session but I dont seem to get any response when I write the user name to the camera -  I havnt been able to get any response writing anything. Im using python 2.7 and windows xp.  here is the code:<br>
[code]<br>>>>import sys<br>>>>import telnetlib<br>>>>HOST = "10.31.18.21"<br>>>>USER = "admin"<br>>>>tn = telnetlib.Telnet(HOST)<br>>>>tn.read_until("Login: ")<br>
"Welcome to In-Sight(R) 4001 Session 1\r\nUser:"<br>>>>tn.write(USER + "\r\n")<br>>>>tn.read_until("User: ")<br>Traceback (most recent call last):<br>  File "<stdin>", line 1, in <module><br>
  File "C:\Python27\lib\telnetlib.py", line 319,<br>    return self.read_very_lazy()<br>  File "C:\Python27\lib\telnetlib.py", line 395,<br>    raise EOFError, 'telnet connection closed'<br>EOFError: telnet connection closed<br>
>>><br>[\code]<br><br>if i do a read_all instead of read_until for user I just get "..." returned.  Im assuming tn.write command isnt working?  any help would be greatly appreciated.<br><br>thank you<br>
<br>Chris<span class="HOEnZb"><font color="#888888"><br>-- <br><a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br></font></span></div></blockquote>
</div><br></div>