paramiko-expect: Paramiko-expect Timeout Issue
Hi Team,
I’m using paramiko expect for automating one of my terminal session, however I’m facing an issue with the prompt, please find below the error
>>> import paramiko
>>> import re
>>> from paramiko_expect import SSHClientInteraction
>>>
>>> client = paramiko.SSHClient()
>>> client.load_system_host_keys()
>>> client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
>>> client.connect(hostname='172.19.0.120', username='default', password='default', port =2222)
>>> interact = SSHClientInteraction(client, timeout=5, encoding='utf-8', display=True, buffer_size=100000)
>>> prompt = re.escape('.*$ ')
>>> interact.expect(prompt)
CFS:default@Z18044492 [~]$
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/paramiko/channel.py", line 683, in recv
out = self.in_buffer.read(nbytes, self.timeout)
File "/usr/local/lib/python3.5/dist-packages/paramiko/buffered_pipe.py", line 160, in read
raise PipeTimeout()
paramiko.buffered_pipe.PipeTimeout
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.5/dist-packages/paramiko_expect.py", line 144, in expect
current_buffer = self.channel.recv(self.buffer_size)
File "/usr/local/lib/python3.5/dist-packages/paramiko/channel.py", line 685, in recv
raise socket.timeout()
socket.timeout
>>>
Please help me on how to solve this issue?
About this issue
- Original URL
- State: open
- Created 6 years ago
- Comments: 15 (4 by maintainers)
I think I found the problem. As a quick fix, you can change default_match_prefix to ‘.*’ in first expect call:
I had the same issue, just changed the prompt on the very first command I send to the remote machine prompt=“AUTO>” interact.send(f"PS1=‘{prompt}’") and keep running