Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expect and waitfor error with ValueError #225

Open
sjstewart opened this issue Apr 19, 2023 · 4 comments
Open

Expect and waitfor error with ValueError #225

sjstewart opened this issue Apr 19, 2023 · 4 comments

Comments

@sjstewart
Copy link

sjstewart commented Apr 19, 2023

I'm trying to connect to a telnet server that has a Linux system connected to it, issue a newline character, and use either waitfor or expect (something using regular expressions) to match and get the output. I am able to get this to work consistently using read_until:

tn.read_until(b'#', 5)
''
tn.read_until(b'#', 5)
'# hithere\r\nroot@localhost:~# '

However, expect gives me this "negative seek position" error:

tn.expect(['#'], 1)
Traceback (most recent call last):
File "", line 1, in
File "/u/stewarts/.local/lib/python3.7/site-packages/Exscript/protocols/telnetlib.py", line 752, in expect
return self._waitfor(relist, timeout, True, cleanup=cleanup)
File "/u/stewarts/.local/lib/python3.7/site-packages/Exscript/protocols/telnetlib.py", line 691, in _waitfor
self.cookedq.seek(qlen - search_window_size)
ValueError: Negative seek position -150

After seeing telnetlib is deprecated I was looking for a drop in replacement and this seemed the closest.

Edit: I think this is using exscript 2.6.28 and it is on Debian 10 with python 3.7.3

@knipknap
Copy link
Owner

Can you try if the problem also exists in Version a48030c?

@sjstewart
Copy link
Author

It looks like the version I'm using does have that change to collections.py.

@knipknap
Copy link
Owner

Every version since does ;-), but the question was whether you have the same problem with the version from this particular commit. Because there were some changes after that that may have caused the problem.

@sjstewart
Copy link
Author

Ahhh, gotcha. I checked out the code as of that commit and gave it another try, it looks like it happens the same:

tn.write(b'# testing\n')
tn.expect(['#'],1)
Traceback (most recent call last):
File "", line 1, in
File "/u/stewarts/.local/lib/python3.7/site-packages/Exscript/protocols/telnetlib.py", line 705, in expect
return self._waitfor(relist, timeout, True, cleanup=cleanup)
File "/u/stewarts/.local/lib/python3.7/site-packages/Exscript/protocols/telnetlib.py", line 644, in _waitfor
self.cookedq.seek(qlen - search_window_size)
ValueError: Negative seek position -150
tn.waitfor(['#'],1)
Traceback (most recent call last):
File "", line 1, in
File "/u/stewarts/.local/lib/python3.7/site-packages/Exscript/protocols/telnetlib.py", line 698, in waitfor
return self._waitfor(relist, timeout, False, cleanup)
File "/u/stewarts/.local/lib/python3.7/site-packages/Exscript/protocols/telnetlib.py", line 644, in _waitfor
self.cookedq.seek(qlen - search_window_size)
ValueError: Negative seek position -150

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants