Python 无法打开文件
Python can't open file
我有一个 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文件的所有者,并且所有者有执行权限,怎么会打不开文件呢?
Python 解释器必须打开文件进行读取,因此需要执行位和读取位。试试这个:
$ chmod 550 /transform/python_code/edit_doc_with_new_demo_info.py
您需要 运行 python 脚本的读取权限。
我有一个 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文件的所有者,并且所有者有执行权限,怎么会打不开文件呢?
Python 解释器必须打开文件进行读取,因此需要执行位和读取位。试试这个:
$ chmod 550 /transform/python_code/edit_doc_with_new_demo_info.py
您需要 运行 python 脚本的读取权限。