远程机器安装了Cygwin,我已经完成了
$echo "PATH=\$PATH:/cygdrive/c/Python27" >> .bash_profile
then, source .bash_profile (after doing this I am able to run a Python script from cygwin terminal).
现在,从我的笔记本电脑中安装的Pyscripter,我试图通过paramiko在远程机器上运行hello_world:
import paramiko
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect('135.24.237.167',username = 'cyg_server',password = 'force')
stdin,stdout,stderr = ssh.exec_command("/cygdrive/c/Python27/python /cygdrive/c/cygwin64/home/hello_world.py")
##But I get the following error:
stderr.readlines()
[u"C:\\Python27\\python.exe: can't open file '/cygdrive/c/cygwin64/home/hello_world.py': [Errno 2] No such file or directory\r\n"]
请帮忙。
答案 0 :(得分:0)
Paramiko太原始了,我相信。尝试使用面料。
示例代码为:
from fabric.api import *
env.key_filename = /path/to/your/pem/file
def mem_usage():
run('free -m')
execute(mem_usage, host="user@IP_or_hostname")
或者,如果您没有pem文件,则可以保留该行,并在出现提示时输入密码。