简体   繁体   中英

run python script on local machine stored on remote server

I would like to execute a python script stored on a remote server on a local machine. This is so I can keep the code for the script on the server without the user having a copy. Is this possible using python?

I am basically trying to secure the code, possibly behind a username and/or password so that way I can easily update the codebase. (Much like using ssh - but the python script is executed on the local machine instead of the server.)

Edit:

Using curl and process substitution this may be achievable:

execute bash script from URL

so that to execute the python script the command is:

python <(curl "http://example.com/test.py" -s -N)

curl also supports password protection which is ideal.

When I execute the script the root path for the script is /dev/fd. When I navigate to this directory and list directory only contains numbers.

Using the above command as an example, is the script downloaded? (and where to). I notice that if I execute the script in a directory such as Desktop it is not downloaded to that location (the working directory).

You can compile the Python code into compiled Python.pyc files and distribute these files, though the local machine should have the same Python environment as the server.
However it is also not impossible for this code to be decompiled.
https://python-compiler.com/post/how-to-distribute-python-program

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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