telnet.read_until() from telnetlib

  • Thread starter Jacek =?iso-8859-2?Q?Pop=B3awski?=
  • Start date
J

Jacek =?iso-8859-2?Q?Pop=B3awski?=

I have strange problem with telnetlib.

r=self.telnet.read_until(expected,timeout)

It works in most cases (hundrets of iterations), but sometimes "r" doesn't
contain "expected", first I thought that server is responding incorrectly, then
I realized that read_until doesn't wait timeout seconds!

example output (value of r):

"#"

while I was expecting "config#"

value of timeout is 20

PS. Python 2.4.1, Cygwin.
 
S

sp1d3rx

Czesc Jacek:
Please post the minimum code necessary to duplicate the problem.

Dzieki,
Derek Wilson
 
S

sp1d3rx

after doing some research, I would suggest trying self.telnet.expect().
This will give you more data about the cause of the failures.
 
J

Jacek =?iso-8859-2?Q?Pop=B3awski?=

my said:
Please post the minimum code necessary to duplicate the problem.

It's impossible, because I am writting performance tests for big commercial
project, I am trying to understand why they sometime fail. By definition of
"read_until()" it should return expected data (if it doesn't wait timeout
seconds).
Anyway, I am trying to use "telnet.expect" now, thanks.
 
J

Jacek =?iso-8859-2?Q?Pop=B3awski?=

I have same problem with expect :-(

I am calling:

l=[expected]
result=self.telnet.expect(l,timeout)

it works in most cases, but sometimes (with exacly same "expected" value) it
returns -1,Nil,"some text"
the point is, that:
- connection is still active, so it should read more!
- it doesn't wait timeout seconds (I used time.time() to check that, time is
zero, timeout is about 20s)!

In what case "expect" or "read_until" will stop reading without waiting for
timeout?
 
S

sp1d3rx

but the 'expect' gives you more details about the failure... read the
documentation on telnet objects here:
"http://docs.python.org/lib/telnet-objects.html".
It says this specifically:
"If end of file is found and no text was read, raise EOFError.
Otherwise, when nothing matches, return (-1, None, text) where text is
the text received so far (may be the empty string if a timeout
happened). "
 
J

Jacek =?iso-8859-2?Q?Pop=B3awski?=

my said:
"If end of file is found and no text was read, raise EOFError.
Otherwise, when nothing matches, return (-1, None, text) where text is
the text received so far (may be the empty string if a timeout
happened). "

What if:
- exception has not been raised
and:
- time passed is smaller than timeout?
How to interpret such behaviour?
 
S

sp1d3rx

then you are using a regex expression that is a wildcard match, and
that is non-deterministic.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,266
Messages
2,571,318
Members
47,998
Latest member
GretaCjy4

Latest Threads

Top