【问题标题】:Python File Handling Script not working when integrating with php与 php 集成时,Python 文件处理脚本不起作用
【发布时间】:2017-10-08 10:34:07
【问题描述】:

shell.php:

<?php
shell_exec("python /opt/lampp/htdocs/web_test/script.py ")
?>

script.py:

fo = open("/opt/lampp/htdocs/web_test/hello.txt", "w")
fo.write( "Python is a great language.\nYeah its great!!\n")
fo.close()

【问题讨论】:

  • shell.php
  • 尝试提供 python 二进制文件的完整路径,例如 /usr/bin/python 并确保运行它的用户可以读取 script.py (www-data ?)
  • 还不行
  • PHP 端有什么错误吗? web_test 目录也是可写的吗? is_writable("/opt/lampp/htdocs/web_test") 通过?

标签: php python shell file-handling


【解决方案1】:

检查写入权限

is_writable("/opt/lampp/htdocs/web_test")

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-16
    • 1970-01-01
    • 2021-06-12
    • 1970-01-01
    • 1970-01-01
    • 2013-01-16
    相关资源
    最近更新 更多