Open voetsjoeba opened 7 years ago
just of curiosity ? do you really need the echo of your own command ? :)
Well no, that's the issue, right? It's been a while since I reported this so forgive if I'm wrong, but as I understand it, current_output
includes the command you sent, because the remote TTY echoes it back to you as you send it -- that's to be expected. current_output_clean
is meant to fix that by looking for the command string you sent at the start of the output and stripping it off.
However, when the command is sufficiently long, it apparently gets these extra spaces inserted at TTY wrapping points, and the string match that the cleaner does to look for the command now fails. So now this chopped-up version of the command you sent appears in current_output_clean
, while it should not be there at all.
o.k. now I get the problem you are talking about... I think I have a fix, I'll upload a branch, so you can check it out
@voetsjoeba please take this branch, and tell me if this solves your issue, cause this change is a bit tricky, and might break existing code for people.
I want to make sure it's actully solves your problem, before commit this to master and issuing a new release
see the branch, I've create for this issue. meanwhile I'm marking this as wontfix.
I am running into this same issue. I modified my existing paramiko_expect.py with the branch changes you provided, but now it doesn't recognize the expect. It works prior to your changes but adds the spaces.
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(ip, username=username, password=password)
interact = SSHClientInteraction(ssh, timeout=60, display=False)
interact.expect('Prompt')
for adj in list_of_adj:
interact.send(adj)
interact.expect('Prompt')
output = interact.current_output_clean
outputList.append([adj, output])
ssh.close()
If you send a command whose length + the prompt length exceeds the tty_width, spaces are inserted into the command line that gets echoed back out at positions where it linewraps. This breaks output cleaning because the echoed command line no longer matches the input.
On my Ubuntu 16.04 box, my banner and prompt looks like this:
Note that the prompt
vmuser@vm:~$
has a space at the end, i.e. it is 13 characters long.On this machine, running
prints:
Replace the
"a"*100
with"a"*10
, and it works as expected: