2

I've got a small c++ script on my raspberry pi which I want to execute from PHP on my small webserver, when I run the following command in my CLI the code executes : "/home/pi/kaku 1 a on". But when I run the following PHP code on my webserver shell_exec("/home/pi/kaku 1 a on"); the code that gets triggered by php simply doesn't run, When I don't give in any parameters by running shell_exec("/home/pi/kaku"); Than I simply get response that I need to fill in the parameters. The c++ code can be found overhere: https://github.com/chaanstra/raspKaku

The permissions of /home/pi/kaku has been set to 777 by using chmod for testing purposes. I am wondering why is my code not running?

Erwin Vorenhout
  • 181
  • 1
  • 5
  • 20
  • What about `shell_exec("/home/pi/kaku a 1 on")` (change order of the first and second argument) ? Because from the code on github, the second argument should be a number : `device = atol(argv[2]);` If `argv[2]` does not begin with 0-9, device will be 0 ? – Zimmi May 06 '17 at 08:17
  • Doesn't seem to resolve my issue, I created a bash file , which simply run the same command which I run in the CLI if I run the bash script from the CLI the programm works, when I run the l bash script from Shell_EXEC is simply doesn't work, I added a echo in the bashfile, the echo is returned to my webbrowser – Erwin Vorenhout May 06 '17 at 21:46
  • Issue was due rights of the www-data user, http://stackoverflow.com/questions/538939/php-exec-will-not-execute-shell-command-when-executed-via-browser – Erwin Vorenhout May 07 '17 at 19:15

0 Answers0