如何使用PuTTY从脚本执行服务器上的命令?

时间:2018-03-06 12:04:53

标签: python putty

使用ssh命令可以传递参数,告诉它在远程服务器上运行命令。我试图达到同样的目的,但是用PuTTY。

我的Windows机器上安装了PuTTY,安装到C:。我试图从本地Python脚本调用它,并让它在服务器上调用命令show system info

这是我想到的那种伪Python:

import ssh
server=ssh.Connection(host='10.201.20.240')
result=server.execute('show system info')

更具体地说,使用Python脚本中的PuTTY,就像这样(当然不对,否则我不会问这个)

command = '"c:\Putty\putty.exe"  -ssh   user@10.201.20.240 -pw admin 10.201.20.240 '
result=command.execute('show system info') 
subprocess.Popen(command)

如果这是ssh命令,我会使用ssh … user@10.201.20.240 show system info等等。

用于执行此操作的Windows PuTTY程序的命令行语法是什么?

0 个答案:

没有答案
相关问题