0

I try to execute this command with the PHP command exec:

exec ("gphoto2 --capture-image-and-download --filename ".$path, $output, $returnVal);

I use a valid filename and when I execute the command with the parameters of the variables in bash, it works. However, with php it doesn't. I don't get a reply of the exec command.
I'm using raspbian with lighty and the php5 module. That works with other samples fine. I tryed shell_exec without success, too.

Can someone help me?

Samane
  • 500
  • 7
  • 23
  • *"I don't get a reply of the exec command"* - What exactely does `exec()` return? Is `gphoto2` in the path for the corresponding user? – m02ph3u5 Oct 03 '15 at 16:15
  • It's like the command is missing. There is nothing happen. When I use `command -v gphoto2` for locating gphoto2. I get this path: `/usr/local/bin/gphoto2` –  Oct 04 '15 at 10:15
  • Sometime, I get the exit code 127 –  Oct 04 '15 at 12:09
  • And have you looked up what *127* means? What happens when you take the full path? – m02ph3u5 Oct 04 '15 at 18:03
  • I tryed it with this command `/usr/local/bin/gphoto2 --capture-image-and-download --filename photo_`. Sometimes I get the return code 127 which means _"command not found"_ or code 1 which means _"Catchall for general errors"_. If I use the same command on bash, it works fine. That's the source: http://tldp.org/LDP/abs/html/exitcodes.html –  Oct 06 '15 at 07:21
  • Get the path and check if `/usr/local/bin` is in there. `var_dump(exec('which gphoto2'))` - `var_dump(exec('echo $PATH'))`. – m02ph3u5 Oct 06 '15 at 09:04
  • The replys of teh var_dumps: `var_dump(exec('which gphoto2'))`: `string(0) ""` `var_dump(exec('echo $PATH'))`: `string(29) "/sbin:/bin:/usr/sbin:/usr/bin"` Is that what you need? –  Oct 06 '15 at 20:25
  • As m02ph3u5 suggested, it does not look like gphoto2 is in the PATH when the PHP is run. Use `exec("/usr/local/bin/gphoto2 ...)` or add /usr/local/bin to the PATH in the PHP environment for the script. – gstrauss Sep 26 '16 at 06:16

0 Answers0