在Python包Paramiko中,channel.py
和client.py
中存在exec_command
方法,它们之间有什么区别?
Channel
是一个低级API,一般不应该使用。
SSHClient.exec_command
调用Channel.exec_command
,然后创建stdin
/stdout
/stderr
对象,并将它们作为3- double返回。使用Channel
,您将不得不自己创建这些对象(因为没有它们,Channel.exec_command
是无用的)。
参见Paramiko exec_command fails with 'NoneType'对象不可迭代。
此外,SSHClient.exec_command
具有分别触发Channel.get_pty()
和Channel.update_environment
的get_pty
和environment
参数。
检查SSHClient.exec_command
源代码