Reputation: 1229
Running subprocess works locally on Windows but does not work when I add the script on the linux box and run it. A subprocess object does get created but it just hangs and waits there.
This is the script I am running:
p = subprocess.Popen(["php", "random.php", username, password], stdout=subprocess.PIPE, shell=True)
p.wait()
I've looked at php ini, disabled functions and it's empty. I've tried to add a a = p.communicate()
and print a
but this doesn't print anything
I'm running out of things I can do, is there anything else I can do to debug why it doesn't work?
Thanks
Upvotes: 1
Views: 839
Reputation: 140188
A good lead would be that the process blocks because you're using redirection, but not consuming the output. Depending on the operating system and buffer sizes, this may or may not work.
If the process ends without outputting too much so the output pipe doesn't fill up, it'll work, else it'll block.
It seems that you don't want the output, you just want to make the process quiet. In that case, do not redirect with subprocess.PIPE
Python 3 has subprocess.DEVNULL
p = subprocess.Popen(["php", "random.php", username, password], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
Python 2 hasn't, but you can fake it
with open(os.devnull,"w") as f:
p = subprocess.Popen(["php", "random.php", username, password], stdout=f, stderr=f)
then:
rc =p.wait()
and check return code
Upvotes: 1