首先,我搜索与主题相关的所有主题,但没有得到输出。 我通过PHP的exec函数(exec,shell_exec,passthru,system)运行Python脚本,但结果未在浏览器上显示(白屏)。所以,我在CLI中测试,它有效!!!我得到结果。
readpython.php:
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
$command = escapeshellcmd("sudo python /var/www/html/access01/scripts/readRFID.py");
$output = shell_exec($command);
echo $output;
?>
readrfid.py:
#!/usr/bin/env python
import RPi.GPIO as GPIO
import SimpleMFRC522
reader = SimpleMFRC522.SimpleMFRC522()
try:
id, text = reader.read()
print(id)
#print(text)
finally:
GPIO.cleanup()
还有其他方法可以在浏览器上显示结果吗? 还是我的服务器中缺少某些库或扩展? 我使用apache2,mariaDB,PHP7.0和Python2.7.12
最诚挚的问候。
答案 0 :(得分:0)
python
和/path/to/.py
之间应该有一个空格