I am using paramiko for SSH with my remote devices.
and I am make communication with them using paramiko shell (invoke_shell()
method) for interactivity.
The main problem with paramiko shell (as I've read in many answers here) is that there is no guarantee that paramiko SSHClient methods which indicates that the server finished writing such as recv_exit_status()
and exit_status_ready()
will behave as expected.
So I created mechanism that will read the last line of the output from the shell and determine if this line contains only shell's prompt in such case the command execution was finished.
This is works in case there is no changes in prompt.
Now I've read here Wait until task is completed on Remote Machine through Python that 'exec_command()' method return tuple 'stdin, stdout, stderr' and preforming stdout.channel.recv_exit_status()
will block channel until it is done.
My question is if I will create such a tuple and will preform stdout.channel.recv_exit_status()
with stdout
that I will get when I am open on each interactive command (meaning I will do 'shell_chan.send('something')' and then will do stdout.channel.recv_exit_status()
) will it do the job? will it return only when interactive command has finished?