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
echo date >> /etc/motion/bleh.txt
touch /etc/motion/touchme
/usr/bin/msmtp -t < tonymsg
It's supposed to write date and time to bleh.txt, update the timestamp of touchme, and send the contents of tonymsg via msmtp
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 .
drwxr-xr-x 68 root root 4096 Apr 11 05:36 ..
-rw-r--r-- 1 motion motion 2668 Apr 11 10:42 blarg.txt
-rw-r----- 1 root motion 24272 Apr 3 13:35 motion.conf
-rwxr-xr-x 1 tony tony 139 Apr 11 10:45 sendtony.sh
-rw-r--r-- 1 root root 2385 Apr 3 13:20 thread1.conf
-rw-r--r-- 1 root root 2548 Apr 11 10:45 thread2.conf
-rw-r--r-- 1 root root 2110 Aug 10 2010 thread3.conf
-rw-r--r-- 1 root root 2625 Aug 10 2010 thread4.conf
-rwxr-xr-x 1 tony tony 152 Apr 10 15:36 tonymsg
-rwxrwxrwx 1 root root 9 Apr 11 10:39 touchme
Notice that the timestamp on touchme is 10:39, but I restarted the motion daemon at 10:42.
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
Thu Apr 11 10:42:27 EDT 2013
Thu Apr 11 10:42:28 EDT 2013
Thu Apr 11 10:42:28 EDT 2013
Thu Apr 11 10:42:34 EDT 2013
Thu Apr 11 10:42:34 EDT 2013
Thu Apr 11 10:42:35 EDT 2013
Thu Apr 11 10:42:35 EDT 2013
Thu Apr 11 10:42:36 EDT 2013
Thu Apr 11 10:42:36 EDT 2013
Thu Apr 11 10:42:37 EDT 2013
Thu Apr 11 10:42:37 EDT 2013
Thu Apr 11 10:42:38 EDT 2013
Thu Apr 11 10:42:38 EDT 2013
Thu Apr 11 10:42:39 EDT 2013
Also, notice the absence of bleh.txt. sendtony.sh should have written that file as well.
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
-rw-r--r-- 1 motion motion 58 Apr 11 11:03 bleh.txt
-rwxrwxrwx 1 root root 9 Apr 11 11:03 touchme
(The time stamps have updates, indicating that the script is in fact called by the motion deamon)
So, well, I'm pretty stumped again.