Hi,
I am trying each time an alarm is trigger to execute a python script
When i execute my script from cli it is working
when it is execute from Zone Minder i catch this error
ERR Command '/home/pi/python/ZoneMinderFilter.py /ramdisk/4/397' exited with status: 120
do you know why ?
thx
filter executing an external python script
Re: filter executing an external python script
Have you tried running the script as the apache or www-data user? (Or whatever your distro provides.)
If that works, can you capture any runtime output or errors when ZM runs the script, perhaps by writing it to a file with something like this as the command in ZM:
I'm not sure if that will work though as Zm may well place other parameters at the end of the line which might mess things up.
Code: Select all
su -s /bin/bash --command="/home/pi/python/ZoneMinderFilter.py /ramdisk/4/397" apache
Code: Select all
/home/pi/python/ZoneMinderFilter.py >logfile 2>&1
Re: filter executing an external python script
hi
i did what you advise
but the main problem is that zoneminder add /ramdisk/4/401 at all commands
Command 'su -s /bin/bash --command="/home/pi/python/ZoneMinderFilter.py" apache /ramdisk/4/401' exited with status: 1
do you know why?
Regards
i did what you advise
but the main problem is that zoneminder add /ramdisk/4/401 at all commands
Command 'su -s /bin/bash --command="/home/pi/python/ZoneMinderFilter.py" apache /ramdisk/4/401' exited with status: 1
do you know why?
Regards
Re: filter executing an external python script
by hand
root@raspberrypi:/home/pi# /home/pi/python/ZoneMinderFilter.py /ramdisk/4/398/ 1>logfile2>&1
root@raspberrypi:/home/pi# cat logfile2
/ramdisk/4/398/
4
398
rclone copy /ramdisk/4/398//398-video.mp4 googledrive:398-video.mp4
/usr/bin/rclone link googledrive:398-video.mp4
b'https://drive.google.com/open?id=1RBVoi ... 8ntl4oHo\n'
echo "b'https://drive.google.com/open?id=1RBVoi ... 8ntl4oHo\n'" | /home/pi/python/SendMail.py LINK3
root@raspberrypi:/home/pi# /home/pi/python/ZoneMinderFilter.py /ramdisk/4/398/ 1>logfile2>&1
root@raspberrypi:/home/pi# cat logfile2
/ramdisk/4/398/
4
398
rclone copy /ramdisk/4/398//398-video.mp4 googledrive:398-video.mp4
/usr/bin/rclone link googledrive:398-video.mp4
b'https://drive.google.com/open?id=1RBVoi ... 8ntl4oHo\n'
echo "b'https://drive.google.com/open?id=1RBVoi ... 8ntl4oHo\n'" | /home/pi/python/SendMail.py LINK3
Re: filter executing an external python script
you are right my ZM seems to run under www-data user
root@raspberrypi:/home/pi# ps -ef |grep zm
www-data 773 1 0 15:09 ? 00:00:01 /usr/bin/perl -wT /usr/bin/zmdc.pl startup
www-data 819 773 48 15:09 ? 01:24:06 /usr/bin/zmc -m 4
www-data 824 773 0 15:09 ? 00:00:01 /usr/bin/perl -wT /usr/bin/zmfilter.pl --filter_id=1 --daemon
www-data 832 773 0 15:09 ? 00:00:01 /usr/bin/perl -wT /usr/bin/zmfilter.pl --filter_id=2 --daemon
www-data 853 773 0 15:09 ? 00:00:04 /usr/bin/perl -wT /usr/bin/zmaudit.pl -c
www-data 859 773 0 15:09 ? 00:00:01 /usr/bin/perl -wT /usr/bin/zmwatch.pl
www-data 873 773 0 15:09 ? 00:00:00 /usr/bin/perl -wT /usr/bin/zmtelemetry.pl
www-data 879 773 0 15:09 ? 00:00:00 /usr/bin/perl -wT /usr/bin/zmstats.pl
www-data 19955 773 0 17:44 ? 00:00:02 /usr/bin/perl -wT /usr/bin/zmfilter.pl --filter_id=3 --daemon
root 20617 20240 0 18:01 pts/1 00:00:00 grep zm
root@raspberrypi:/home/pi# ps -ef |grep zm
www-data 773 1 0 15:09 ? 00:00:01 /usr/bin/perl -wT /usr/bin/zmdc.pl startup
www-data 819 773 48 15:09 ? 01:24:06 /usr/bin/zmc -m 4
www-data 824 773 0 15:09 ? 00:00:01 /usr/bin/perl -wT /usr/bin/zmfilter.pl --filter_id=1 --daemon
www-data 832 773 0 15:09 ? 00:00:01 /usr/bin/perl -wT /usr/bin/zmfilter.pl --filter_id=2 --daemon
www-data 853 773 0 15:09 ? 00:00:04 /usr/bin/perl -wT /usr/bin/zmaudit.pl -c
www-data 859 773 0 15:09 ? 00:00:01 /usr/bin/perl -wT /usr/bin/zmwatch.pl
www-data 873 773 0 15:09 ? 00:00:00 /usr/bin/perl -wT /usr/bin/zmtelemetry.pl
www-data 879 773 0 15:09 ? 00:00:00 /usr/bin/perl -wT /usr/bin/zmstats.pl
www-data 19955 773 0 17:44 ? 00:00:02 /usr/bin/perl -wT /usr/bin/zmfilter.pl --filter_id=3 --daemon
root 20617 20240 0 18:01 pts/1 00:00:00 grep zm
Re: filter executing an external python script
I suspect that the script may not be executable by, or that some file is inaccessible to, the www-data user.
Try this at the command line:
Try this at the command line:
Code: Select all
su -s /bin/bash --command="/home/pi/python/ZoneMinderFilter.py /ramdisk/4/397" www-data
Re: filter executing an external python script
from root this command works !
root@raspberrypi:/home/pi/python# su -s /bin/bash --command="/home/pi/python/ZoneMinderFilter.py /ramdisk/4/397" www-data
/ramdisk/4/397
4
397
rclone copy /ramdisk/4/397/397-video.mp4 googledrive:397-video.mp4
/usr/bin/rclone link googledrive:397-video.mp4
b'https://drive.google.com/open?id=1JpyVR ... xUF0BW6x\n'
echo "b'https://drive.google.com/open?id=1JpyVR ... xUF0BW6x\n'" | /home/pi/python/SendMail.py LINK3
root@raspberrypi:/home/pi/python# su -s /bin/bash --command="/home/pi/python/ZoneMinderFilter.py /ramdisk/4/397" www-data
/ramdisk/4/397
4
397
rclone copy /ramdisk/4/397/397-video.mp4 googledrive:397-video.mp4
/usr/bin/rclone link googledrive:397-video.mp4
b'https://drive.google.com/open?id=1JpyVR ... xUF0BW6x\n'
echo "b'https://drive.google.com/open?id=1JpyVR ... xUF0BW6x\n'" | /home/pi/python/SendMail.py LINK3
Re: filter executing an external python script
thanks to you i find the trick !!!
well, i allow www-data to do su (adding in /etc/passwd on the www-data line => /bin/bash)
i configured www-data user to be able to copy on googledrive with rclone
now it is working with that command in filter ==> /home/pi/python/ZoneMinderFilter.py
THANKS YOU !
well, i allow www-data to do su (adding in /etc/passwd on the www-data line => /bin/bash)
i configured www-data user to be able to copy on googledrive with rclone
now it is working with that command in filter ==> /home/pi/python/ZoneMinderFilter.py
THANKS YOU !
Re: filter executing an external python script
Good to hear it's fixed - It sounds like the www-data user didn't have a shell configured
The "proper"/"safe" way to add or change a user's shell or other data is with usermod though, which'll update /etc/passwd and any other relevant files...
The "proper"/"safe" way to add or change a user's shell or other data is with usermod though, which'll update /etc/passwd and any other relevant files...
Code: Select all
usermod -s /bin/bash www-data