I\'m having a hard time understanding how the recv() function works.
http://docs.paramiko.org/en/1.13/api/channel.html#paramiko.channel.Channel.recv
Channel recv() corresponds to a socket.recv(), it does not have any specific structure or size, it just reads whatever data was sent from the remote server, not exceeding maxBytes.
You commonly use recv() in a loop until you get a piece of data that you are waiting for:
def _wait_for_data(self, options, verbose=False):
chan = self.chan
data = ""
while True:
x = chan.recv(1024)
if len(x) == 0:
self.log("*** Connection terminated\r")
sys.exit(3)
data += x
if verbose:
sys.stdout.write(x)
sys.stdout.flush()
for i in range(len(options)):
if re.search(options[i], data):
return i
return -1