Open mpenning opened 2 years ago
With libtelnet
being deprecated as of 3.11 and removal slated for 3.13 I was looking for an alternative package. Exscript is suggested in the PEP which lead me to this issue.
I modified my local Protocol.py in Exscript and was able to get interactive working with two changes.
Change 1 on line 1145: set mode to rb
instead of r
https://github.com/knipknap/exscript/blob/a20e83ae3a78ea7e5ba25f07c1d9de4e9b961e83/Exscript/protocols/protocol.py#L1145
Change 2 on line 1145: the first change will now require a bytes
object instead of str
, so instead of sending data
send bytes(data, 'utf-8')
https://github.com/knipknap/exscript/blob/a20e83ae3a78ea7e5ba25f07c1d9de4e9b961e83/Exscript/protocols/protocol.py#L1199
My script now works with this:
import sys
from Exscript import Account
from Exscript.protocols import Telnet
account = Account('username', 'password')
conn = Telnet(stdout=sys.stdout)
conn.set_prompt('/ #')
conn.connect('<ip_address>')
conn.authenticate(account)
conn.interact() # blocking
conn.close()
I'm not confident this won't cause issues else where, but I figured I would share a possible solution.
I can establish normal SSH2 sessions with Exscript. However, when I use
conn.interact()
, I getexscript
tracebacks... fancy super-useful tracebacks courtesy ofloguru
Sadly, I don't know enough linux / exscript details to contribute to fixing the problem, but
interact()
is definitely broken in exscript 2.6.3.Background: