在远程服务器上运行本地 python 脚本 [英] Run local python script on remote server
问题描述
我正在调试一些必须在我的虚拟机上运行的 python 脚本.而且,我更喜欢在本地(虚拟机之外)编辑脚本.因此,我发现每次将 scp
修改的脚本都乏味 到虚拟机.任何人都可以提出一些有效的方法吗?
I'm debugging some python script that must run on my virtual machine. And, I prefer to edit the scripts locally(outside of virtual machines). So I find it's tedious to scp
modified scripts to virtual machines every time. Can anyone suggests some effective way?
特别是,我想知道是否可以在远程 PVM 上执行 python 脚本.类似的东西:
Particularly, I'm wondering if it's possible to execute python scripts on remote PVM. Something like that:
python --remote user@192.168.1.101 hello.py //**FAKED**, served to explain ONLY
推荐答案
可以使用 ssh.Python 接受连字符(-) 作为参数来执行标准输入,
It is possible using ssh. Python accepts hyphen(-) as argument to execute the standard input,
cat hello.py | ssh user@192.168.1.101 python -
运行 python --help 以获取更多信息.
Run python --help for more info.
这篇关于在远程服务器上运行本地 python 脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!