motion daemon not able to send email (debian)
I've installed and configured motion to run as a daemon. Right now, all I want it to do is detect motion and then execute a command. At the moment, the program will detect motion, and then log the date and time to a text file located in /etc/motion. That much is working. I've put this line in the config file for that camera:
Code:
on_motion_detected date >> /etc/motion/blarg.txt I also have this line in the config file: Code:
on_motion_detected sh /etc/motion/sendtony.sh The contents of that script are: Code:
#!bin/bash Code:
To: REDACTED@REDACTED.com msmtp uses the universal config file (not the best solution, but for testing, that's how it's set up) msmtprc located at /etc/msmtprc. Its contents follows: Code:
account default Since I think it's a permissions issue, I checked the owners, groups, and permissions, and it seems to me that they should all be readable and executable by any user on the system (again, not the best solution, but I'll restrict it once I get this testing finished) Code:
drwxrwxrwx 2 root root 4096 Apr 10 16:04 . And here's the permissions of the config file for msmtp: Code:
-rw-r--r-- 1 root root 257 Apr 7 19:40 msmtprc So, why can't the motion daemon run that script? :-( P.S. Debian on a SheevaPLug uname output: Code:
Linux debian-tony-server 2.6.32-5-kirkwood #1 Mon Feb 25 13:55:40 UTC 2013 armv5tel GNU/Linux |
probably a path problem.
but first, if you start your script with sh: sh <path>/<yourscript> you would not need #!/bin/bash at the beginning (not to speak about that sh and bash are not the same, so you would also need to select which one to use. Insert a line into that script, for example touch <somefile> to check if it started (if that file was created or not). Use full path to msmtp, proably it was not found |
Thank you Pan64 for the reply. I had no idea about the sh and bash thing you mentioned. I believe you, but I'm surprised, since that's how I was taught in my Intro to Linux class a few quarters ago. Although, admittedly, the instructor for that course was not very familiar with Linux.
So I modified the script to follow your advice. I added the full path, and then I also added a line to touch the file touchme. (I created the file touchme, and then changed its permissions to 777. Then, for good measure, I changed that script to write date and time info to a different file than the configuration file for the motion daemon, so that I'd know which entity (the motion daemon, or my script) is writing the date and time. Here's sendtony.sh Code:
#!bin/bash AH HAH! Now we are getting somewhere! If you look at the contents of /etc/motion, it becomes evident that the motion daemon is performing the command to write date and time on motion, but not calling the script (or it is calling it, but it cannot execute). Code:
drwxrwxrwx 2 root root 4096 Apr 11 10:41 . Here's the output of blarg.txt that shows that the motion daemon did detect motion, and executed the first instruction Code:
Thu Apr 11 10:42:27 EDT 2013 So I was again stumped, but then thought that perhaps in the config file, I should take out the second on_motion_detect directive, since maybe it was overriding the second one, and it was! So no, when there is motion detected, the motion daemon executes the sendtony.sh script, which does write the date and time, and does update the time stamp of touchme, but still does not send the email. :-( Code:
root@debian-tony-server:/etc/motion# ls -l | grep bleh && ls -l | grep touch So, well, I'm pretty stumped again. |
so you can also try to insert the following line:
exec 2>> /etc/motion/error.log And hopefully you will get some error message |
All times are GMT -5. The time now is 05:30 PM. |