我需要执行一些ssh命令。我找到了一些例子,但它是针对一个命令的,例如'pwd':
endpoint = SSHCommandClientEndpoint.newConnection(reactor, 'pwd',
username, host, port,
password=password,
agentEndpoint=agent
)
factory = MonitoringFactory()
d = endpoint.connect(factory)
d.addCallback(lambda protocol: protocol.finished)
例如,pwi应该执行什么命令。我应该做两个端点吗?对吗?但是它可以建立2个ssh连接,不是吗?在我看来,应该有另一种方法来做我想做的事。在
使用
SSHCommandClientEndpoint.existingConnection
在单个SSH连接上运行多个命令。在请记住,这些命令仍然不会在同一个shell会话中运行。因此,您可能不一定会发现
pwd
之类的命令非常有用。在如果要在单个shell会话中运行多个命令,则需要使用shell组合命令:
^{pr2}$相关问题 更多 >
编程相关推荐