The php part:
Code: Select all
<?php
$command = "/var/www/bin/TakeAnotherPic.sh";
echo "<H1>Taking a picture at the moment...</H1>\n";
$output = shell_exec($command);
echo "$output";
?>Code: Select all
#!/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
whoami #debug
/usr/bin/fswebcam -v -r 640x480 /var/www/webcam/$(date +\%Y-\%m-\%d-\%H-\%M).jpg 2> /var/www/bin/fswebcam.txt
When running the script from php web page (confirmed user is www-data), the script excecutes, but the fswebcam part fails with error messages:
Code: Select all
--- Opening /dev/video0...
Trying source module v4l2...
Error opening device: /dev/video0
open: Permission denied
Trying source module v4l1...
Error opening device: /dev/video0
open: Permission denied
Unable to find a source module that can read /dev/video0.Code: Select all
# ls -la /dev/video0
crw-rw---T 1 root video 81, 0 Nov 6 10:35 /dev/video0Code: Select all
# grep video /etc/group
video:x:44:pi,www-dataHow come the permissions for www-data are different when executing the script from php or from command line? What am I missing here? I suspect an easy fix, but what on earth is it?
Thanks