【发布时间】:2021-11-04 04:03:42
【问题描述】:
在Python包Paramiko中,channel.py和client.py中存在exec_command方法,它们有什么区别?
【问题讨论】:
在Python包Paramiko中,channel.py和client.py中存在exec_command方法,它们有什么区别?
【问题讨论】:
Channel 是一个低级 API,一般不应使用。
SSHClient.exec_command 调用 Channel.exec_command,然后创建 stdin/stdout/stderr 对象并将它们作为 3-touple 返回。使用Channel,您必须自己创建这些对象(因为没有它们,Channel.exec_command 将毫无用处)。
另见Paramiko exec_command fails with 'NoneType' object is not iterable。
此外,SSHClient.exec_command 具有 get_pty 和 environment 参数,分别触发 Channel.get_pty() 和 Channel.update_environment。
【讨论】: