Python无法打开文件

时间:2015-09-18 19:58:35

标签: php python apache permission-denied

我有一个PHP脚本应该以用户“apache”执行python脚本但是返回错误:

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

edit_doc_with_new_demo_info.py的权限为---xrwx--x. 1 apache PosixUsers 4077 Sep 18 12:14 edit_doc_with_new_demo_info.py。调用此python脚本的行是:

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

如果apache是python文件的所有者且所有者具有执行权限,那么它怎么能无法打开文件?

2 个答案:

答案 0 :(得分:6)

Python解释器必须打开读取的文件,因此需要执行和读取位。试试这个:

$ chmod 550 /transform/python_code/edit_doc_with_new_demo_info.py

答案 1 :(得分:1)

您需要具有读取权限才能运行python脚本。

相关问题