2

I have a PHP script that is supposed to execute a python script as user "apache" but is returning the error:

/transform/anaconda/bin/python: can't open file '/transform/python_code/edit_doc_with_new_demo_info.py': [Errno 13] Permission denied

Permissions for edit_doc_with_new_demo_info.py are ---xrwx--x. 1 apache PosixUsers 4077 Sep 18 12:14 edit_doc_with_new_demo_info.py. The line that is calling this python script is:

shell_exec('/transform/anaconda/bin/python /transform/python_code/edit_doc_with_new_demo_info.py ' . escapeshellarg($json_python_data) .' >> /transform/edit_subject_python.log 2>&1')

If apache is the owner of the python file and the owner has execute permission how can it be unable to open the file?

asked Sep 18, 2015 at 19:58

2 Answers 2

6

The Python interpreter has to open the file for reading, so both the execute and read bits are required. Try this:

$ chmod 550 /transform/python_code/edit_doc_with_new_demo_info.py
answered Sep 18, 2015 at 20:01
Sign up to request clarification or add additional context in comments.

3 Comments

correct me if I'm wrong, but I assume the same occurs with any interpreter of sort (e.g. PHP)
Practically speaking, yes, all interpreters require read permission of their script files.
Oh wow, I never would have guessed that. So you need read access whenever a script calls another script or only when you are passing something between scripts?
1

You need read permission to run the python script.

answered Sep 18, 2015 at 20:01

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.