Run local python script on remote server

qweruiop picture qweruiop · Dec 10, 2013 · Viewed 96.9k times · Source

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?

Particularly, I'm wondering if it's possible to execute python scripts on remote PVM. Something like that:

python --remote [email protected] hello.py //**FAKED**, served to explain ONLY

Answer

asdfg picture asdfg · Apr 7, 2014

It is possible using ssh. Python accepts hyphen(-) as argument to execute the standard input,

cat hello.py | ssh [email protected] python -

Run python --help for more info.