btidey wrote: ↑Thu Dec 21, 2017 5:10 pm
ohiojoe wrote: ↑Thu Dec 21, 2017 11:28 am
1.
When I generate motion, files are recorded, email is sent, but no upload to dropbox.
If I execute ./end_box.sh from the command line, the email fails with this error: File "/home/pi/./email_webcam.py", line 26, in <module>
subject = sys.argv[1]
IndexError: list index out of range
Is this because the email_webcam.py was previously successful? The $1 sys.argv[1] is not available?
The dropbox_uploader.sh then works as expected.
Uploading "/var/www/media/vi_0029_20171221_183912.mp4" to "/media/vi_0029_20171221_183912.mp4"...
Done.
2.
From the RPi environment, the email part works as expected. But no upload.
My end_box.sh code:
Code: Select all
#!/bin/bash
python /home/pi/./email_webcam.py $1
/home/pi/Dropbox-Uploader/dropbox_uploader.sh -h -p upload /var/www/media/$1 /$1
Code: Select all
#!/bin/bash
python /home/pi/./email_webcam.py $1
#/home/pi/Dropbox-Uploader/dropbox_uploader.sh -h -p upload /var/www/media/$1 /$1
date >/var/www/uploadtest.txt
output from end_box.sh
/var/www $ cat uploadtest.txt
Thu Dec 21 19:16:34 +08 2017
So it looks like the end_box.sh macro is working...just not the dropbox_uploader.sh code. Does that (dropbox_uploader.sh) have to have owner in the www-data group also?
Yes. www-data probably doesn't have permission to either execute the dropbox script or something within it (maybe curl). First check the execution permissions of the dropbox_uploader.sh and set it to execute by everybody.
- pi@CarPort_Cam:~/Dropbox-Uploader $ ls -la
total 140
drwxr-xr-x 3 pi pi 4096 Dec 21 09:18 .
drwxr-xr-x 8 pi pi 4096 Dec 21 15:31 ..
-rw-r--r-- 1 pi pi 8348 Nov 28 14:02 CHANGELOG.md
-rw-r--r-- 1 pi pi 286 Nov 28 14:02 Dockerfile
-rwxr-xr-x 1 www-data www-data 47825 Nov 28 14:02 dropbox_uploader.sh
One can also run a command as a different user from the command line using sudo
sudo -u www-data command
Code: Select all
pi@CarPort_Cam:/var/www/macros $ sudo -u www-data ./end_box.sh
Traceback (most recent call last):
File "/home/pi/./email_webcam.py", line 26, in <module>
subject = sys.argv[1]
IndexError: list index out of range
> Creating Directory "/media"... FAILED
> Uploading "/var/www/media/vi_0004_20171221_220726.mp4" to "/media/vi_0004_20171221_220726.mp4"...
######################################################################## 100.0%
DONE
So it does execute with the sudo -u www-data command, but not in the RPi environment. I did change permissions to dropbox_uploader.sh to -rwxr-xr-x 1 www-data www-data 47825 Nov 28 14:02 dropbox_uploader.sh
But still doesn't execute. ;(
I also added www-data to the 'sudo' group, but no change. ( I removed 'sudo' from www-data before running sudo -u www-data ./end_box.sh)
sudo deluser www-data sudo
Removing user `www-data' from group `sudo' ...
Done.
pi@CarPort_Cam:~/Dropbox-Uploader $ groups www-data
www-data : www-data video pi
Yes. www-data probably doesn't have permission to either execute the dropbox script or something within it (maybe curl).
I don't know anything about curl to change any permissions with it.
Thanks for your generous time and support!