I'm using Paramiko to ssh into a telecom switch that doesn't support using the exec_command(). So i'm using invoke_shell() and send() instead.
What i'm trying to do is ssh, exec a cmd, then sftp the file. Here's a snippet.
<code>
chan.send(cmd4)
time.sleep(5)
if chan.recv_ready():
result = chan.recv(1024)
while chan.recv_ready():
result += chan.recv(1024)
print(result)
exit_status = chan.recv_exit_status()
if exit_status == 0:
try:
sftp = ssh.open_sftp()
sftp.get(remotePath,path)
sftp.close()
except:
print "sftp error"
else:
print("exit status not 0")
chan.close()
</code>
The problem is the command can take anyway from 10mins to 2 hours depending on the switch. So how would i wait until the command is finished before i try to sftp?