Send empty command before recv

On some switches, starting an SSH connection and immediately calling
recv() will result in a connection timeout. The switch requires some
input on the channel before it provides any prompt.

As such, this patch sends an empty command immediately upon connection,
triggering the switch to send a prompt which the shell can then
interpret.

Signed-off-by: Devananda van der Veen <devananda.vdv@gmail.com>
This commit is contained in:
Devananda van der Veen 2016-03-09 17:15:11 -08:00
parent 9318727021
commit 08f270ad71
No known key found for this signature in database
GPG key ID: 845BEE06788983A7

View file

@ -109,6 +109,7 @@ class Shell(object):
self.shell = self.ssh.invoke_shell()
self.shell.settimeout(10)
self.shell.sendall("\n")
self.receive()
def strip(self, data):