473,395 Members | 1,462 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

telnet.read_until() from telnetlib

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.

--
Free Software - find interesting programs and change them
NetHack - meet interesting creatures, kill them and eat their bodies
Usenet - meet interesting people from all over the world and flame them
Decopter - unrealistic helicopter simulator, get it from http://decopter.sf.net
Aug 26 '05 #1
7 12453
Czesc Jacek:
Please post the minimum code necessary to duplicate the problem.

Dzieki,
Derek Wilson

Aug 26 '05 #2
after doing some research, I would suggest trying self.telnet.expect().
This will give you more data about the cause of the failures.

Aug 26 '05 #3
my newsreader told me that sp*****@gmail.com wrote:
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.

--
Free Software - find interesting programs and change them
NetHack - meet interesting creatures, kill them and eat their bodies
Usenet - meet interesting people from all over the world and flame them
Decopter - unrealistic helicopter simulator, get it from http://decopter.sf.net
Aug 29 '05 #4
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?

--
Free Software - find interesting programs and change them
NetHack - meet interesting creatures, kill them and eat their bodies
Usenet - meet interesting people from all over the world and flame them
Decopter - unrealistic helicopter simulator, get it from http://decopter.sf.net
Aug 29 '05 #5
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). "

Aug 30 '05 #6
my newsreader told me that sp*****@gmail.com wrote:
"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?
--
Free Software - find interesting programs and change them
NetHack - meet interesting creatures, kill them and eat their bodies
Usenet - meet interesting people from all over the world and flame them
Decopter - unrealistic helicopter simulator, get it from http://decopter.sf.net
Aug 31 '05 #7
then you are using a regex expression that is a wildcard match, and
that is non-deterministic.

Sep 1 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Jinming Xu | last post by:
Hello Everyone, I am trying to write a python script to telnet to a server and then do something there. As the first step, I practiced the python example in Lib Reference 11.13.2. But I am...
3
by: Adam Flott | last post by:
I'm having some difficulty getting the expect function of telnetlib to capture some data that gets returned from a telnet connection. Python's telnet debug reports this: recv...
3
by: Yannick Turgeon | last post by:
Hello all, I'm currently trying to pass commands to a telnet session and get the texte generated (stdin + stdout) by the session. The problem I get is that the Telnet.read_until() function...
4
by: Donnal Walter | last post by:
On Windows XP I am able to connect to a remote telnet server from the command prompt using: telnet nnn.nnn.nnn.nnn 23 where nnn.nnn.nnn.nnn is the IP address of the host. But using telnetlib,...
2
by: eight02645999 | last post by:
hi i am using a telnet session to simulate an authentication mechanism USER = "user" PASSWORD = "password" try: telnet = telnetlib.Telnet(HOST) telnet.set_debuglevel(5)...
2
by: Arne | last post by:
Hello! Task: Connecting to a unix server and getting the directory list . OS: XP Connecting to the server via telnet is no problem. I also want to get the directory list. I know by using...
13
by: Godzilla | last post by:
Hello, How do you create/spawn new processes in XP over telnet using python? I.e. I would like to create a new process and have it running in the background... when I terminate the telnet...
1
by: sreejithp | last post by:
Hello, I am new to python. I have been trying to connect to telnet and feed some data from a server. Its working properly. I used the connectionObj.read_until() method to read the data from the...
1
by: Hishaam | last post by:
Hi, In python documentation, i found a telnet example as follows: ------------------------------------------------------------------------- import getpass import sys import telnetlib HOST...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.