Expect and waitfor error with ValueError
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
Can you try if the problem also exists in Version a48030c?
It looks like the version I'm using does have that change to collections.py.
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.
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