Paramiko: Piping blocks forever on read

丶灬走出姿态 提交于 2019-12-04 02:11:14

With some investigation, it appears that stdin.close() does not actually end the bash session. To do that, you could use the bash command exit (stdin.write('exit\n')) or dig into the paramiko Channel object underneath the stdin object:

stdin.channel.shutdown_write()

If you'd like the bash session to continue for another command, you'll need to use the channel object directly. The documentation for Channel mentions recv_ready(self) and recv(self, nbytes) which will allow you t check for the data before you try to get it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!