skip to Main Content

I’m trying to run a Python script which is hosted on a different server. I have access to both servers. I’ve tried to use an Apache server with a php script which runs the python script and returns the output, using shell_exec(). But it seems like its capping at 100 (while I can still run the file myself when logged in as root). My question about that is right here: https://serverfault.com/questions/1017357/centos-php-processes-limited-with-shell-exec.

Is there another way to run the Python script which is hosted on my server, from another python script on my pc?

Thanks for your time!

2

Answers


  1. Either you can use subprocess.call module which will run it as a child process or you can use something like this.

    (This is to run python from a file. You may modify it accordingly to download it and run)

        with open(file, 'r') as f:
            code = compile(f.read(), file, 'exec')
            exec(code)
    
    Login or Signup to reply.
  2. You can try using this

    from subprocess import run, PIPE
    import sys
    
    run([sys.executable,"python_script_location"],shell = False, stdout = PIPE)
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search