fgimian / paramiko-expect

A Python expect-like extension for the Paramiko SSH library which also supports tailing logs.
MIT License
204 stars 78 forks source link

Problem with sending long commands #56

Closed gandraman closed 4 years ago

gandraman commented 4 years ago

Hi,

I made a wrapper for Paramiko, which helps me to connect to (mainly Cisco IOS-XR) devices using Linux server as jumphost. So I first SSH to jumphost using Paramiko and from there I jump further using Linux ssh. However, when sending slightly longer commands in Paramiko shell, they get strangely echoes, for example:

RP/0/RP0/CPU0:ROUTER#show rpl route-policy TESTING-ROUTING-POLICY deta$NG-ROUTING-POLICY

The command that should have been sent it: show rpl route-policy TESTING-ROUTING-POLICY detail

Here is the code excerpt that is responsible for receiving data:

` def expect(self, patterns, timeout=0): self.__before.clear() wait = 0

    if not isinstance(patterns, list):
        patterns = [patterns]

    while True:
        time.sleep(SSH.poll_sleep) # default 0.5s
        if self.shell.recv_ready():
            found_pattern = None
            received = self.shell.recv(8192)
            received = received.decode()

            if self.doprint:
                print(received, end='')

.....`

Do you know what might be causing the issue like that? Thanks, Dragan

gandraman commented 4 years ago

Opening issue at Paramiko,