-3

I wrote a PHP file to control my wireless socket with 433 MHz. I want to run it in my local network by typing in the browser: "ip of server"/socketOn.php It is not going to turn on the socket. This is my PHP code:

machine("sudo /home/pi/raspberry-remote/./send 11000 4 1");
Striezel
  • 3,693
  • 7
  • 23
  • 37
  • 1
    To the best of my knowledge, PHP doesn't have a `machine()` function. You will want to look at these instead: http://stackoverflow.com/questions/732832/php-exec-vs-system-vs-passthru – Markus AO Dec 26 '16 at 18:02

1 Answers1

0

As Markus AO already mentioned in his comment, there is no machine() function in PHP. You should use exec(), system(), shell_exec() or similar PHP functions to execute a shell command.

The code could then look like this, assuming that /home/pi/raspberry-remote/send is executable:

<?php
exec("/home/pi/raspberry-remote/send 11000 4 1");
?>

Note that some restrictions may apply to these functions, if PHP runs in safe mode. According to the official PHP documentation, for exec(), system() and passthru() these restrictions are:

You can only execute executables within the safe_mode_exec_dir. For practical reasons it's currently not allowed to have .. components in the path to the executable. escapeshellcmd() is executed on the argument of this function.

Striezel
  • 3,693
  • 7
  • 23
  • 37