0

I wrote a PHP script that processes some task for me (specifically, encoding videos on a media server). I tested calling this script via python like so:

proc = subprocess.Popen("php vodworkflow_drm_playready_widevine.php videos " +str(video), shell=True, stdout=subprocess.PIPE)

This worked correctly (i.e. the video name passed to the script got correctly encoded and such). However, when I call Popen from inside my Django project, I instead get the output: Could not open input file: my_script.php.

I'm stumped! Can anyone help with what could be going on, and what I can do to rectify this? Thanks, I've been stuck since a while now. Do let me know if you need to see the PHP script and more detailed code.

1 Answer 1

2

Point the php file to php binary by its full path.

proc = subprocess.Popen("php /root/www/bla_bla/vodworkflow_drm_playready_widevine.php videos " +str(video), shell=True, stdout=subprocess.PIPE)

Alternatively, Popen takes an cwd argument. Specify the path to it.

https://docs.python.org/3/library/subprocess.html#using-the-subprocess-module

http://sharats.me/the-ever-useful-and-neat-subprocess-module.html#execute-in-a-different-working-directory

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

Comments

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.