擅长:python、mysql、java
<p>当<code>stdout.channel.exit_status_ready()</code>开始返回<code>True</code>时,远程端可能仍有大量数据等待发送。但您只收到一个2048字节的块并退出。你知道吗</p>
<p>不必检查退出状态,您可以继续调用<code>recv(2048)</code>,直到它返回一个空字符串<a href="http://docs.paramiko.org/en/2.4/api/channel.html#paramiko.channel.Channel.recv" rel="nofollow noreferrer">which means</a>,表示不再有数据出现:</p>
<pre><code>output = ''
next_chunk = True
while next_chunk:
next_chunk = stdout.channel.recv(2048)
output += next_chunk
</code></pre>
<p>但实际上你可能只是想:</p>
<pre><code>output = stdout.read()
</code></pre>