我想逃跑发光.py'(纽扣罗恩)和'lightledoff.py'(按钮ROFF)通过PHP。这两个程序都包含GPIO库并需要根用户访问。按钮“开”和“关”直接打开和关闭led。Button ON和OFF都能正常工作,但是RON和ROFF不能。我如何运行需要根访问权限的python或c++程序?在
LED TestLight Led
Radio Led
On Board Led for Test
if ($_GET["button"] == "RON") {
system("echo raspberry | sudo -S python ./lightled.py");
};
if ($_GET["button"] == "ROFF") {
system("echo raspberry | sudo -S python ./lightledoff.py");
};
if ($_GET["button"] == "ON") {
system("gpio -g mode 17 out");
system("gpio -g write 17 1");
};
if ($_GET["button"] == "OFF") {
system("gpio -g mode 17 out");
system("gpio -g write 17 0");
};
?>