【问题标题】:Python CGI script not working as hoped?Python CGI 脚本没有按预期工作?
【发布时间】:2015-06-23 11:55:34
【问题描述】:

我正在尝试使用 WiringPi、Apache 和 CGI​​ python 脚本通过 Raspberry Pi 的 GPIO 运行电机。这是我的 CGI 脚本:

#!/usr/bin/python
import wiringpi2
wiringpi2.wiringPiSetupSys()

wiringpi2.pinMode(11,1)
wiringpi2.pinMode(13,1)
wiringpi2.digitalWrite(11,1)
wiringpi2.digitalWrite(13,0)

print "Status: 204 No Content"
print "Content-type: text/plain\n\n"

我已经导出了引脚 11 和 13,上面的代码在没有“sudo”的情况下通过终端完美地运行电机,但是当我通过服务器(在 localhost 和另一个浏览器中)将其作为 CGI 运行时电机不旋转在局域网上)。我什至没有遇到任何错误。 Apache 错误日志中也没有任何内容。

我尝试将标题更改为打印 html,一切正常,但电机似乎没有让步。

【问题讨论】:

  • 另外,我注意到我的 /var/log/apache2/error.log 有点坏了。自在 Leafpad GUI 中打开 1 周以来,它没有显示任何错误,但我可以在终端的 nano 编辑器中看到新错误。尽管如此,仍然没有与我的代码相关的错误。

标签: apache cgi


【解决方案1】:

使用 chmod 使文件可执行。但是我仍然不确定如果它不是可执行的,我是如何从程序中获得 html 输出的。

【讨论】:

    猜你喜欢
    • 2014-05-07
    • 2019-06-16
    • 2012-02-06
    • 2012-05-10
    • 1970-01-01
    • 2022-12-17
    • 2012-05-09
    • 2014-02-26
    • 1970-01-01
    相关资源
    最近更新 更多