简体   繁体   English

在远程服务器上执行本地python脚本(未安装python)

[英]Executing local python script on remote server(which has no python installed)

I have 2 servers ie local and remote server but the remote server has no python installed in it.Both servers have windows installed in it. 我有2个服务器,即本地和远程服务器,但是远程服务器中没有安装python。两个服务器都安装了Windows。 I want to execute a local python script on remote server without installing python on remote server. 我想在远程服务器上执行本地python脚本而不在远程服务器上安装python。 For example I have local python script 'zip.py': 例如,我有本地python脚本“ zip.py”:

filenames = ['a.txt','b.txt','c.txt']
zf = zipfile.ZipFile('files.zip', mode='w')
for fname in filenames:
    zf.write(fname)
zf.close()
print

Another script to connect to remote server and execute 'zip.py' on remote server: 连接到远程服务器并在远程服务器上执行“ zip.py”的另一个脚本:

rem.py Rem.py

ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect('15.111.109.123', username='ABC', password='123')
sftp = ssh.open_sftp()
sftp.put(local_path,remote_path)   #to transfer zip.py from local to remote
stdin,stdout,stderr=ssh.exec_command("zip.py")

But the local python script is not getting executed on remote server. 但是本地python脚本未在远程服务器上执行。 How exactly to make it execute on remote server?? 如何使其在远程服务器上执行? I want do execute using script itself,not by installing cygwin and then doing ssh to the server. 我想使用脚本本身执行,而不是通过安装cygwin然后对服务器执行ssh来执行。

Maybe your looking for a portable executable (a program that doesn't need to be installed to run). 也许您正在寻找可移植的可执行文件(无需安装即可运行的程序)。 Here are some python ones: 这里是一些python:

  1. WinPython : "The easiest way to run Python, Spyder with SciPy and friends out of the box on any Windows PC, without installing anything!" WinPython“在任何Windows PC上无需安装任何东西即可开箱即 用地 运行Python,带有SciPy的Spyder和朋友的最简单方法!”

  2. Anaconda 水蟒

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM