0

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).

4
  • What you have in remote server, windows or linux? Commented Nov 6, 2019 at 16:55
  • either, hopefully with the potential to be on a web server Commented Nov 6, 2019 at 16:57
  • It's probably easier to just freeze the python code with pyinstaller or cx_freeze and distribute to the clients instead... Commented Nov 6, 2019 at 17:06
  • @r.ook thanks but i really need the code base to be in one place rather than distributed, so at this point it will be much easier for me to update the script Commented Nov 6, 2019 at 17:21

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

But this does not solve the code being in many different places.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.