PHP 433 MHz Raspberry Pi

时间:2016-12-26 17:14:23

标签: php raspberry-pi

我写了一个PHP文件来控制433 MHz的无线套接字。我想通过在浏览器中输入“在服务器的IP”/socketOn.php中在本地网络中运行它 它不会打开套接字。 这是我的PHP代码:

machine("sudo /home/pi/raspberry-remote/./send 11000 4 1");

1 个答案:

答案 0 :(得分:0)

正如Markus AO在他的评论中已经提到的,PHP中没有machine()函数。您应该使用exec()system()shell_exec()或类似的PHP函数来执行shell命令。

假设/home/pi/raspberry-remote/send是可执行的:

,代码可能如下所示
<?php
exec("/home/pi/raspberry-remote/send 11000 4 1");
?>

如果PHP在restrictions may apply to these functions中运行,请注意一些safe mode。根据官方PHP文档,对于exec()system()passthru()这些限制是:

  

您只能在safe_mode_exec_dir内执行可执行文件。出于实际原因,目前不允许在可执行文件的路径中包含..组件。 escapeshellcmd()在此函数的参数上执行。