Python包Paramiko中,
exec_command
和channel.py
中存在client.py
方法,它们有什么区别?
Channel
是一个低级 API,一般情况下不应使用。
SSHClient.exec_command
调用Channel.exec_command
,然后创建stdin
/stdout
/stderr
对象并将它们作为三元组返回。使用 Channel
,您必须自己创建这些对象(因为没有它们,Channel.exec_command
是无用的)。
另请参阅 Paramiko exec_command 因“NoneType”对象不可迭代而失败。
此外,
SSHClient.exec_command
还有get_pty
和environment
参数,分别触发Channel.get_pty()
和Channel.update_environment
。
SSHClient.exec_command
源代码。