{"id":1805,"date":"2015-08-13T15:47:21","date_gmt":"2015-08-13T14:47:21","guid":{"rendered":"https:\/\/stevepedwards.today\/DebianAdmin\/?p=1805"},"modified":"2025-07-03T17:29:01","modified_gmt":"2025-07-03T16:29:01","slug":"using-sendemail-curl-for-a-motion-alert-and-hacking-its-2-year-old-perl-tls-bug","status":"publish","type":"post","link":"https:\/\/stevepedwards.today\/DebianAdmin\/using-sendemail-curl-for-a-motion-alert-and-hacking-its-2-year-old-perl-tls-bug\/","title":{"rendered":"Using Sendemail + Curl For a Motion Alert and Hacking Its 2+ year old Perl TLS Bug"},"content":{"rendered":"<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_1805\" class=\"pvc_stats all  \" data-element-id=\"1805\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/stevepedwards.today\/DebianAdmin\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n<p>After studying the conf file for Motion looking for an Email Alert function of some kind, I found:<\/p>\n<p><span style=\"color: red;\"># Command to be executed when an event starts. (default: none)<br \/>\n<\/span><\/p>\n<p><span style=\"color: red;\"># An event starts at first motion detected after a period of no motion defined by gap<br \/>\n<\/span><\/p>\n<p><span style=\"color: red;\">; on_event_start value<br \/>\n<\/span><\/p>\n<p>I thought about using sendemail as the value\u00a0that could send a message and attach a jpg of a motion event.<\/p>\n<p>This opened up a real can of worms because of an unfixed, 2+ year long issue with Perl modules, and research to get the command structure, jpg file name to be useable and an insight into the Perl programmers world that I never even knew existed.<\/p>\n<p><strong>SendEmail<br \/>\n<\/strong><\/p>\n<p>Years ago, when security was less stringent, you could use these command line programs to send a quick email to an SMTP server on port 25. No encryption required, just an account, uname and password about as simple as things could be.<\/p>\n<p>Now, for various reasons and advantages for us all for privacy, spam blocking etc. SSL (Secure Sockets Layer) and TLS (Transport Layer Security) are used by most providers like gmail, on ports 465 or 587, so an example line to use for sendemail may be:<\/p>\n<p><span style=\"color: #0070c0; font-family: Helvetica; font-size: 9pt; background-color: white;\">sendEmail -t xxx@gmail.com -f picam@spoofed.com -xu uname -xp password -a \/attach.jpg -m \"msg\" -u \"subject\" \u00a0-o tls=auto -s smtp.gmail.com:587<br \/>\n<\/span><\/p>\n<p>For more\u00a0switches, use the -h help, or man page.<\/p>\n<p>So far, so good? No.<\/p>\n<p>Test this line works before using it in Motion because it probably won't work, depending on what OS, updates, perl modules, and wot-not you have!<\/p>\n<p>I got fault lines similar to:<\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: red;\">Aug 13 14:49:15 piblanc sendemail[4810]: NOTICE =&gt; Authentication not supported by the remote SMTP server!<br \/>\n<\/span><\/p>\n<p><span style=\"color: red;\">Aug 13 14:49:16 piblanc sendemail[4810]: ERROR =&gt; Received: 530 5.7.0 Must issue a STARTTLS command first. h6sm3520159wiy.3 - gsmtp<br \/>\n<\/span><\/p>\n<p>then:<\/p>\n<p><span style=\"color: #ff0000;\">invalid SSL_version specified at \/usr\/local\/share\/perl\/5.14.2\/IO\/Socket\/SSL.pm line xxx:<\/span><\/p>\n<p>This seems to be an old bug, and it took a while to research and sent me down an educational but incorrect path regarding CSPAN (eh?), and doing updates for Perl modules that was intriguing, but did not solve the issue completely.<\/p>\n<p>How can this be, that such an old problem has not been fixed in some?\/most? linux distribs, including Apple?<\/p>\n<p>I found info and forums about this, including the programmer's homepage which really pissed me off that he hasn't got it fixed, with the pathetically vague help text shown below:<\/p>\n<p><a href=\"https:\/\/caspian.dotconf.net\/menu\/Software\/SendEmail\/\">https:\/\/caspian.dotconf.net\/menu\/Software\/SendEmail\/<\/a><\/p>\n<p><em><span style=\"color: black; font-family: Arial; font-size: 8pt; background-color: white;\"><strong>TLS Support<\/strong><\/span><span style=\"color: #5b69a6; font-family: Arial; font-size: 8pt;\"><strong><br \/>\n<span style=\"background-color: white;\">Starting with sendEmail v1.54, TLS support is included! To enable TLS support <\/span><\/strong><\/span><span style=\"color: red; font-family: Arial; font-size: 8pt; background-color: white;\"><strong>simply<\/strong><\/span><span style=\"color: #5b69a6; font-family: Arial; font-size: 8pt;\"><span style=\"background-color: white;\"><strong> install the\u00a0<\/strong>Net::SSLeay<strong>\u00a0and<\/strong>IO::Socket::SSL<strong>\u00a0perl modules. The following new command line parameters are now available:<\/strong><\/span><strong><br \/>\n<span style=\"background-color: white;\">\u00a0\u00a0\u00a0\u00a0<\/span><\/strong>-o tls=aut<span style=\"background-color: white;\">o<strong>\u00a0This is the default, TLS will be used if possible.<\/strong><\/span><strong><br \/>\n<span style=\"background-color: white;\">\u00a0\u00a0\u00a0\u00a0<\/span><\/strong>-o tls=ye<span style=\"background-color: white;\">s<strong>\u00a0Use this to require TLS for message delivery.<\/strong><\/span><strong><br \/>\n<span style=\"background-color: white;\">\u00a0\u00a0\u00a0\u00a0<\/span><\/strong>-o tls=n<span style=\"background-color: white;\">o<strong>\u00a0Use this to disable TLS support.<\/strong><\/span><strong><br \/>\n<span style=\"background-color: white;\">If TLS is giving strange errors, try upgrading the Net::SSLeay and IO::Socket::SSL perl modules. Please do NOT report TLS bugs unless you have already done this! If you're running up-to-date versions of these modules and you are getting TLS errors, your detailed bug report will be appreciated. <\/span><\/strong><\/span><strong><span style=\"color: red;\"><span style=\"font-family: Arial; font-size: 8pt; background-color: white;\">Yes, you can finally use SendEmail to send messages to your GMail account :<\/span><br \/>\n<\/span><br \/>\n<\/strong><\/em><\/p>\n<p>Really, Mr Programmer...? Have <strong><em>you<\/em><\/strong> tested it? We've been here before recently with Pmagic eh?<\/p>\n<p>What does that even mean unless you are a Perl geek? How do you install\/upgrade those modules?<\/p>\n<p>So, doing his suggested research for ages on google, I wasted more time upgrading unnecessary SSL modules, and failed with SSLeay anyway, when a one character ($) script hack fixes it thanks to some other clever dude that I forget what page I found it.<\/p>\n<p>Anyway, what is debian\/raspbian\/others doing having a known buggy program in the repositories?<\/p>\n<p><a href=\"https:\/\/stackoverflow.com\/questions\/12750662\/install-perl-module-netssleay-through-cpan\">https:\/\/stackoverflow.com\/questions\/12750662\/install-perl-module-netssleay-through-cpan<\/a><\/p>\n<p><a href=\"https:\/\/raspberrypi.stackexchange.com\/questions\/2118\/sendemail-failure\">https:\/\/raspberrypi.stackexchange.com\/questions\/2118\/sendemail-failure<\/a><\/p>\n<p>For interest, I'll show you what the Perl upgrades involve, as I want to keep both Pis as similar as possible, so the other Pi now needs the same treatment.<\/p>\n<p>I did a fresh install on PiBlanc, which for interest, took about 30 mins for dd to complete:<\/p>\n<p style=\"background: white;\"><span style=\"font-family: Arial; font-size: 9pt;\"><span style=\"color: #222222;\">DellMint stevee # <\/span><span style=\"color: #0070c0;\">dd if=\/Pi.img of=\/dev\/sdg<br \/>\n<\/span><\/span><\/p>\n<p style=\"background: white;\"><span style=\"color: red; font-family: Arial; font-size: 9pt;\">15523840+0 records in<br \/>\n<\/span><\/p>\n<p style=\"background: white;\"><span style=\"color: red; font-family: Arial; font-size: 9pt;\">15523840+0 records out<br \/>\n<\/span><\/p>\n<p style=\"background: white;\"><span style=\"color: red; font-family: Arial; font-size: 9pt;\">7948206080 bytes (7.9 GB) copied, 1833.87 s, 4.3 MB\/s<br \/>\n<\/span><\/p>\n<p>30 mins to re-image the default 8GB NOOBS Pi image I saved, to a new 16GB card to re-install from scratch for the 2nd Pi.<\/p>\n<p>Perl Updates command:<\/p>\n<p><span style=\"color: #0070c0;\">perl -MCPAN -e shell<br \/>\n<\/span><\/p>\n<p><span style=\"color: red;\">CPAN.pm requires configuration, but most of it can be done automatically.<br \/>\n<\/span><\/p>\n<p><span style=\"color: red;\">If you answer 'no' below, you will enter an interactive dialog for each<br \/>\n<\/span><\/p>\n<p><span style=\"color: red;\">configuration option instead.<br \/>\n<\/span><\/p>\n<p><span style=\"color: red;\">Would you like to configure as much as possible automatically? [yes]<br \/>\n<\/span><\/p>\n<p>Now, this Q+A goes on for a long while, and as I have no idea what its on about, I just default entered through all of it until:<\/p>\n<p><span style=\"color: red;\">Looking for CPAN mirrors near you (please be patient)<br \/>\n<\/span><\/p>\n<p><span style=\"color: red;\">....... done!<br \/>\n<\/span><\/p>\n<p><span style=\"color: red;\">New urllist<br \/>\n<\/span><\/p>\n<p><span style=\"color: red;\"> https:\/\/CPAN.mirror.rafal.ca\/<br \/>\n<\/span><\/p>\n<p><span style=\"color: red;\"> https:\/\/httpupdate25.cpanel.net\/CPAN\/<br \/>\n<\/span><\/p>\n<p><span style=\"color: red;\"> https:\/\/mirror.csclub.uwaterloo.ca\/CPAN\/<br \/>\n<\/span><\/p>\n<p><span style=\"color: red;\">Autoconfiguration complete.<br \/>\n<\/span><\/p>\n<p><span style=\"color: red;\">commit: wrote '\/root\/.cpan\/CPAN\/MyConfig.pm'<br \/>\n<\/span><\/p>\n<p><span style=\"color: red;\">You can re-run configuration any time with 'o conf init' in the CPAN shell<br \/>\n<\/span><\/p>\n<p><span style=\"color: red;\">Terminal does not support AddHistory.<br \/>\n<\/span><\/p>\n<p><span style=\"color: red;\">cpan shell -- CPAN exploration and modules installation (v1.960001)<br \/>\n<\/span><\/p>\n<p><span style=\"color: red;\">Enter 'h' for help.<br \/>\n<\/span><\/p>\n<p><span style=\"color: red;\">cpan[1]&gt;<br \/>\n<\/span><\/p>\n<p>then do:<\/p>\n<p><span style=\"color: #0070c0;\">cpan[1]&gt; install <span style=\"background-color: white;\">IO::Socket::SSL<\/span><br \/>\n<\/span><\/p>\n<p><span style=\"color: red;\">cpan[1]&gt; install done!<br \/>\n<\/span><\/p>\n<p><span style=\"color: red;\">New urllist<br \/>\n<\/span><\/p>\n<p><span style=\"color: red;\"> https:\/\/CPAN.mirror.rafal.ca\/<br \/>\n<\/span><\/p>\n<p><span style=\"color: red;\"> https:\/\/httpupdate25.cpanel.net\/CPAN\/<br \/>\n<\/span><\/p>\n<p><span style=\"color: red;\"> https:\/\/mirror.csclub.uwaterloo.ca\/CPAN\/<br \/>\n<\/span><\/p>\n<p><span style=\"color: red;\">Fetching with HTTP::Tiny:<br \/>\n<\/span><\/p>\n<p><span style=\"color: red;\">https:\/\/CPAN.mirror.rafal.ca\/authors\/01mailrc.txt.gz<br \/>\n<\/span><\/p>\n<p><span style=\"color: red;\">Autoconfiguration complete.<br \/>\n<\/span><\/p>\n<p><span style=\"color: red;\">commit: wrote '\/root\/.cpan\/CPAN\/MyConfig.pm'<br \/>\n<\/span><\/p>\n<p><span style=\"color: red;\">You can re-run configuration any time with 'o conf init' in the CPAN shell<br \/>\n<\/span><\/p>\n<p><span style=\"color: red;\">Terminal does not support AddHistory.<br \/>\n<\/span><\/p>\n<p>After all that, the SSLEAY failure goes along the lines of:<\/p>\n<p style=\"background: #eeeeee;\"><span style=\"font-family: Consolas; font-size: 10pt;\"><span style=\"color: black;\">cpan[13]&gt; <\/span><span style=\"color: #0070c0;\">install Net::SSLeay<br \/>\n<\/span><\/span><\/p>\n<p style=\"background: #eeeeee;\"><span style=\"color: #ff0000; font-family: Consolas; font-size: 10pt;\">** Found OpenSSL-1.0.1e installed in \/usr<br \/>\n<\/span><\/p>\n<p style=\"background: #eeeeee;\"><span style=\"color: #ff0000; font-family: Consolas; font-size: 10pt;\">*** Be sure to use the same compiler and options to compile your OpenSSL, perl,<br \/>\n<\/span><\/p>\n<p style=\"background: #eeeeee;\"><span style=\"color: #ff0000; font-family: Consolas; font-size: 10pt;\"> and Net::SSLeay. Mixing and matching compilers is not supported.<br \/>\n<\/span><\/p>\n<p style=\"background: #eeeeee;\"><span style=\"color: #ff0000; font-family: Consolas; font-size: 10pt;\">Do you want to run external tests?<br \/>\n<\/span><\/p>\n<p style=\"background: #eeeeee;\"><span style=\"color: #0070c0; font-family: Consolas; font-size: 10pt;\"><span style=\"color: #ff0000;\">These tests *will* *fail* if you do not have network connectivity. [n]<\/span> y<br \/>\n<\/span><\/p>\n<p style=\"background: #eeeeee;\"><span style=\"color: red; font-family: Consolas; font-size: 10pt;\">SSLeay.xs:163:25: fatal error: openssl\/err.h: No such file or directory<br \/>\n<\/span><\/p>\n<p style=\"background: #eeeeee;\"><span style=\"color: red; font-family: Consolas; font-size: 10pt;\">compilation terminated.<br \/>\n<\/span><\/p>\n<p style=\"background: #eeeeee;\"><span style=\"color: red; font-family: Consolas; font-size: 10pt;\">Makefile:353: recipe for target 'SSLeay.o' failed<br \/>\n<\/span><\/p>\n<p style=\"background: #eeeeee;\"><span style=\"color: red; font-family: Consolas; font-size: 10pt;\">make: *** [SSLeay.o] Error 1<br \/>\n<\/span><\/p>\n<p style=\"background: #eeeeee;\"><span style=\"color: red; font-family: Consolas; font-size: 10pt;\"> MIKEM\/Net-SSLeay-1.70.tar.gz<br \/>\n<\/span><\/p>\n<p style=\"background: #eeeeee;\"><span style=\"color: red; font-family: Consolas; font-size: 10pt;\"> \/usr\/bin\/make -- NOT OK<br \/>\n<\/span><\/p>\n<p style=\"background: #eeeeee;\"><span style=\"color: red; font-family: Consolas; font-size: 10pt;\">'YAML' not installed, will not store persistent state<br \/>\n<\/span><\/p>\n<p style=\"background: #eeeeee;\"><span style=\"color: red; font-family: Consolas; font-size: 10pt;\">Running make test<br \/>\n<\/span><\/p>\n<p style=\"background: #eeeeee;\"><span style=\"color: red; font-family: Consolas; font-size: 10pt;\"> Can't test without successful make<br \/>\n<\/span><\/p>\n<p style=\"background: #eeeeee;\"><span style=\"color: red; font-family: Consolas; font-size: 10pt;\">Running make install<br \/>\n<\/span><\/p>\n<p style=\"background: #eeeeee;\"><span style=\"color: red; font-family: Consolas; font-size: 10pt;\"> Make had returned bad status, install seems impossible<br \/>\n<\/span><\/p>\n<p style=\"background: #eeeeee;\"><span style=\"color: red; font-family: Consolas; font-size: 10pt;\">Failed during this command:<br \/>\n<\/span><\/p>\n<p style=\"background: #eeeeee;\"><span style=\"color: red; font-family: Consolas; font-size: 10pt;\"> MIKEM\/Net-SSLeay-1.70.tar.gz : make NO<br \/>\n<\/span><\/p>\n<p style=\"background: white;\"><span style=\"font-family: Consolas; font-size: 10pt;\"><span style=\"color: #0070c0;\">cpan[14]&gt; look Net::SSLeay<\/span><span style=\"color: #222222;\"><br \/>\n<\/span><\/span><\/p>\n<p style=\"background: white;\"><span style=\"color: #0070c0; font-family: Consolas; font-size: 10pt;\">perl Makefile.PL<br \/>\n<\/span><\/p>\n<p style=\"background: white;\"><span style=\"color: red; font-family: Helvetica; font-size: 9pt;\">*** Found OpenSSL-1.0.1e installed in \/usr<br \/>\n<\/span><\/p>\n<p style=\"background: white;\"><span style=\"color: red; font-family: Helvetica; font-size: 9pt;\">*** Be sure to use the same compiler and options to compile your OpenSSL, perl,<br \/>\n<\/span><\/p>\n<p style=\"background: white;\"><span style=\"color: red; font-family: Helvetica; font-size: 9pt;\"> and Net::SSLeay. Mixing and matching compilers is not supported.<br \/>\n<\/span><\/p>\n<p style=\"background: white;\"><span style=\"color: red; font-family: Helvetica; font-size: 9pt;\">Do you want to run external tests?<br \/>\n<\/span><\/p>\n<p style=\"background: white;\"><span style=\"color: red; font-family: Helvetica; font-size: 9pt;\">These tests *will* *fail* if you do not have network connectivity. [n] <strong><span style=\"color: #0000ff;\">Y<\/span><\/strong><br \/>\n<\/span><\/p>\n<p style=\"background: white;\"><span style=\"color: red; font-family: Helvetica; font-size: 9pt;\">Checking if your kit is complete...<br \/>\n<\/span><\/p>\n<p style=\"background: white;\"><span style=\"color: red; font-family: Helvetica; font-size: 9pt;\">Looks good<br \/>\n<\/span><\/p>\n<p style=\"background: white;\"><span style=\"color: red; font-family: Helvetica; font-size: 9pt;\">Writing Makefile for Net::SSLeay<br \/>\n<\/span><\/p>\n<p style=\"background: white;\"><span style=\"color: red; font-family: Helvetica; font-size: 9pt;\">Writing MYMETA.yml<br \/>\n<\/span><\/p>\n<p style=\"background: white;\"><span style=\"color: #0070c0; font-family: Consolas; font-size: 10pt;\">make<br \/>\n<\/span><\/p>\n<p style=\"background: white;\"><span style=\"color: red; font-family: Helvetica; font-size: 9pt;\">SSLeay.xs:163:25: fatal error: openssl\/err.h: No such file or directory<br \/>\n<\/span><\/p>\n<p style=\"background: white;\"><span style=\"color: red; font-family: Helvetica; font-size: 9pt;\">compilation terminated.<br \/>\n<\/span><\/p>\n<p style=\"background: white;\"><span style=\"color: red; font-family: Helvetica; font-size: 9pt;\">Makefile:353: recipe for target 'SSLeay.o' failed<br \/>\n<\/span><\/p>\n<p style=\"background: white;\"><span style=\"color: red; font-family: Helvetica; font-size: 9pt;\">make: *** [SSLeay.o] Error 1<br \/>\n<\/span><\/p>\n<p>So, a waste of time but interesting that all these servers exist for Perl and its modules...<\/p>\n<p>Does sendemail work after the successful SSL install section above?<\/p>\n<p><span style=\"color: red;\">Aug 13 15:10:21 piblanc sendemail[4981]: NOTICE =&gt; Authentication not supported by the remote SMTP server!<br \/>\n<\/span><\/p>\n<p><span style=\"color: red;\">Aug 13 15:10:21 piblanc sendemail[4981]: ERROR =&gt; Received: 530 5.7.0 Must issue a STARTTLS command first. pf4sm3579898wjb.23 - gsmtp<br \/>\n<\/span><\/p>\n<p>No. So...<\/p>\n<p>Googling around, I found:<\/p>\n<p><span style=\"color: #0070c0;\">apt-get install libnet-ssleay-perl<br \/>\n<\/span><\/p>\n<p><span style=\"color: #0070c0;\">apt-get install libio-socket-ssl-perl<br \/>\n<\/span><\/p>\n<p><span style=\"color: #0070c0;\">apt-get install libssl-dev<br \/>\n<\/span><\/p>\n<p>So what does sendemail say now?<\/p>\n<p><span style=\"color: red;\">invalid SSL_version specified at \/usr\/share\/perl5\/IO\/Socket\/SSL.pm line 332<br \/>\n<\/span><\/p>\n<p><strong>The Hack:<br \/>\n<\/strong><\/p>\n<p><span style=\"color: #0070c0;\">vi \/usr\/share\/perl5\/IO\/Socket\/SSL.pm<br \/>\n<\/span><\/p>\n<p>search in vim:<\/p>\n<p>(\/) then paste the term below, and ENTER the term to find it just above where the search line takes you:<\/p>\n<p><strong>m{^(!?)(?:(SSL(?:v2|v3|v23|v2\/3))|(TLSv1[12]?))<span style=\"color: red;\">$<\/span>}i<br \/>\n<\/strong><\/p>\n<p>delete the $ sign, so it changes to:<\/p>\n<p><strong>m{^(!?)(?:(SSL(?:v2|v3|v23|v2\/3))|(TLSv1[12]?))}i<br \/>\n<\/strong><\/p>\n<p>Save in vim (wq!)<\/p>\n<p>Test your sendemail command:<\/p>\n<p><span style=\"color: #0070c0;\">sendemail -t user@gmail.com -f user@gmail.com -xu user -xp pword -a \/Share\/motion\/*35*00.jpg -u \"msg\" -m \"picam test file\" -o tls=auto -s smtp.gmail.com:587<br \/>\n<\/span><\/p>\n<p><span style=\"color: red;\">Aug 13 12:10:28 pinoir sendemail[4749]: Email was sent successfully!<br \/>\n<\/span><\/p>\n<p>The default Motion output jpg naming format is not user friendly, or very amenable to have just one chosen for the sendemail attachment, so you'll have to work out a way to rename them, or whatever to suit yourself, or you may want a video attachment instead if you have fast connections etc:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/stevepedwards.today\/DebianAdmin\/wp-content\/uploads\/2015\/08\/081315_1447_UsingSendem1.png\" alt=\"\" \/><\/p>\n<p><strong>The Summary<br \/>\n<\/strong><\/p>\n<p>Once you have installed the libs, amended the script $ hack, named the Motion output jpgs suitably, or captured a small size video from the type you set in motion.conf, probably not using asterisk wildcards due to the motion naming format to not send yourself tons of unwanted files in the mail, worked out how to not overload the Pi when Motion is capturing jgs and sendemail is trying to access them from the output folder, and send them out, you should get a mail alert containing the jpg of name you chose:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/stevepedwards.today\/DebianAdmin\/wp-content\/uploads\/2015\/08\/081315_1447_UsingSendem2.png\" alt=\"\" \/><\/p>\n<p><strong>What Else?<br \/>\n<\/strong><\/p>\n<p>Now all that's left is to get sendemail to run from inside the motion.conf file - either in motion start or end \u00a0sections?<\/p>\n<p>You have to open ports in your home router, and set a DynDNS service if you have DHCP ADSL to get your home IP address, should you also want to view your camera WAN remotely using Firefox etc. on a port of your choice to watch your live web stream should you get an alert.<\/p>\n<p>Let's hope all that doesn't crash the Pi just as the criminal\/desired event was about to be filmed, or some such...<\/p>\n<p>Good luck with all that.<\/p>\n<p>Later...<\/p>\n<p>I have motion sending .avi files to me by email now, as\u00a0I had missed a msg text for the -m switch initially, so sendemail was waiting for StdIn.<\/p>\n<p>One camera is producing 10 times more jpgs than the other, with the identical conf file?<\/p>\n<p>Also, Piblanc has a brightness\/darkness \"swell\" issue in the live image stream, when Pinoir cam has a stable image right from the start? Odd.<\/p>\n<p>I'm going to diff the conf files to check they make sense...Wow, I missed a few things here!<\/p>\n<p><span style=\"color: #ff0000;\">&lt; v4l2_palette 8<\/span><br \/>\n<span style=\"color: #ff0000;\">---<\/span><br \/>\n<span style=\"color: #ff0000;\">&gt; v4l2_palette 6<\/span><br \/>\n<span style=\"color: #ff0000;\">122c122<\/span><br \/>\n<span style=\"color: #ff0000;\">&lt; auto_brightness off<\/span><br \/>\n<span style=\"color: #ff0000;\">---<\/span><br \/>\n<span style=\"color: #ff0000;\">&gt; auto_brightness on<\/span><br \/>\n<span style=\"color: #ff0000;\">257c257<\/span><br \/>\n<span style=\"color: #ff0000;\">&lt; ffmpeg_cap_new on<\/span><br \/>\n<span style=\"color: #ff0000;\">---<\/span><br \/>\n<span style=\"color: #ff0000;\">&gt; ffmpeg_cap_new off<\/span><br \/>\n<span style=\"color: #ff0000;\">265c265<\/span><br \/>\n<span style=\"color: #ff0000;\">&lt; ffmpeg_timelapse 1<\/span><br \/>\n<span style=\"color: #ff0000;\">---<\/span><br \/>\n<span style=\"color: #ff0000;\">&gt; ffmpeg_timelapse 0<\/span><br \/>\n<span style=\"color: #ff0000;\">298a299<\/span><\/p>\n<p>I guess the auto brightness on\/off is the cause of pinoir's\u00a0cameras image \"swell\". Fixed that...<\/p>\n<p>Now, one camera is producing twice as many jpgs as the other, though\u00a0the capture settings are the same, but no mail is being sent due to a naming error, so the file did not exist.<\/p>\n<p>The easiest and most informative file type and initial name to use as a mail file at first, is a timelapse as *.mpg, as only one is created periodically, and no other, until the next motion start and end period, if that 's what you set.<\/p>\n<p>About 4 mins of timelapse is only about 800k in size, so good as alert info and not too big for an attachment.<\/p>\n<p>The final motion.conf sendemail line that does what I want (so far!) is:<\/p>\n<p><span style=\"color: #ff0000;\">on_event_end sendEmail -t user@gmail.com -f noir@cam.com -a \/Share\/motion\/*.mpg -xu user\u00a0-xp pword\u00a0-s smtp.gmail.com:587 \u00a0-u \"noir cam motion detected !!!\" -m \"noir cam motion detected !!!\"<\/span><\/p>\n<p><a href=\"https:\/\/stevepedwards.today\/DebianAdmin\/wp-content\/uploads\/2015\/08\/MotionTests.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-1813\" src=\"https:\/\/stevepedwards.today\/DebianAdmin\/wp-content\/uploads\/2015\/08\/MotionTests.jpg\" alt=\"MotionTests.jpg\" width=\"1280\" height=\"800\" \/><\/a><\/p>\n<p><a href=\"https:\/\/stevepedwards.today\/DebianAdmin\/wp-content\/uploads\/2015\/08\/MotionTestsCamConfs.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-1816\" src=\"https:\/\/stevepedwards.today\/DebianAdmin\/wp-content\/uploads\/2015\/08\/MotionTestsCamConfs.jpg\" alt=\"MotionTestsCamConfs.jpg\" width=\"1280\" height=\"800\" \/><\/a><\/p>\n<p>Oh! I nearly forgot! Motion complains re PID access for the daemon with a manual start.\u00a0The problem is this happens each start time after a reboot as the PID directory does not exist:<\/p>\n<p><span style=\"color: #0000ff;\">ls -als \/var\/run\/motion\/<\/span><br \/>\n<span style=\"color: #ff0000;\">ls: cannot access \/var\/run\/motion\/: No such file or directory<\/span><\/p>\n<p>From earlier Posts, remember there is another file to enable motion:<\/p>\n<p><span style=\"color: #0000ff;\">vi \/etc\/default\/motion<\/span><\/p>\n<p><span style=\"color: #ff0000;\"># set to 'yes' to enable the motion daemon<\/span><br \/>\n<span style=\"color: #ff0000;\">start_motion_daemon=yes<\/span><\/p>\n<p>I have a problem with the daemon not reading the conf file at boot. The service is starting but the LEDs are flashing, not constant, and there is no action or streaming.<\/p>\n<p>As the manual testing so far was for the conf file in \/etc\/motion using:<\/p>\n<p><span style=\"color: #0000ff;\">motion -c\u00a0\/etc\/motion\/motion.conf<\/span><\/p>\n<p>which tells motion specifically where the conf file is, it may need to be moved to the users default directory called .motion, so as root will be booting it, make it in roots directory:<\/p>\n<p>~<br \/>\n<span style=\"color: #0000ff;\">$ mkdir .motion<\/span><\/p>\n<p><span style=\"color: #0000ff;\">cp -vr \/etc\/motion\/motion.conf \u00a0 \u00a0 \u00a0 \u00a0.motion\/<\/span><\/p>\n<p><span style=\"color: #ff0000;\">'\/etc\/motion\/motion.conf' -&gt; `.motion\/motion.conf'<\/span><\/p>\n<p>reboot to check it comes up with the camera LEDs on.<\/p>\n<p>I did this also, checking perms are the same etc. and it still does not function from boot, as it does manually, like motion is running with an unconfigured conf file...?<\/p>\n<p>Would only happen to me again! I messed up the update-rc command somehow, and removed the links to the \/etc\/init.d\/rc2 dir, so removed and re-installed them (they were visible again) but they did not run.<\/p>\n<p>You have to copy your conf file somewhere safe, then use remove with --purge and auto-remove to completely remove and re-install motion back to defaults (and the conf file so save yours!!) for the links to be replaced properly, then update-rc enable for motion to run at boot.<\/p>\n<p><span style=\"color: #0000ff;\">update-rc motion enable<\/span><\/p>\n<p>One error like that and your chasing dir\/file permissions and god knows what else for nothing.<\/p>\n<p>Phew, what a nightmare again..! I'm obviously not cut out for this Linux Admin stuff...<\/p>\n<p><span style=\"color: #0000ff;\">reboot<\/span><\/p>\n<p>All working now though, and sending me emails.<\/p>\n<p>Also, in gmail, you can send the vids to Gdrive, attach an mpg viewer to Gdrive, and view them directly on the web with no need to DL them to the PC if you don't want.<\/p>\n<p><a href=\"https:\/\/stevepedwards.today\/DebianAdmin\/wp-content\/uploads\/2015\/08\/GDrive.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-1826\" src=\"https:\/\/stevepedwards.today\/DebianAdmin\/wp-content\/uploads\/2015\/08\/GDrive.jpg\" alt=\"GDrive.jpg\" width=\"1280\" height=\"800\" \/><\/a><\/p>\n<p>When you have set up your router to port forward, you can check the WAN IP in Kmeleon\/Firefox to see your camera stream - here my back gate viewed from work:<\/p>\n<p><a href=\"https:\/\/stevepedwards.today\/DebianAdmin\/wp-content\/uploads\/2015\/08\/homemotion.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-1830\" src=\"https:\/\/stevepedwards.today\/DebianAdmin\/wp-content\/uploads\/2015\/08\/homemotion.png\" alt=\"homemotion.jpg\" width=\"1027\" height=\"519\" \/><\/a><\/p>\n<p>Fortunately, the default settings for pixel motion are sensible enough to not alert for the moving plant near the window, visible in the live stream, else I'd be bombed with email all day!<\/p>\n<p><span style=\"color: #ff0000;\"># Threshold for number of changed pixels in an image that<\/span><br \/>\n<span style=\"color: #ff0000;\"># triggers motion detection (default: 1500)<\/span><br \/>\n<span style=\"color: #ff0000;\">threshold 1500<\/span><\/p>\n<p>Pretty cool stuff, even though it all took days to get to grips with.<\/p>\n<p>Each camera and Pi2 set cost about \u00a365 each, and I know there are now much cheaper 4 cam, DVR co-ax systems on Ebay for that, but...this wouldn't be a Linux site then would it?<\/p>\n<p>All that is left now is to sign up with a DynDNS site (the vigor router tells of a vigor offering) to get any changes of DNS sent to me, or accessible, so I don't have to check manually each day before leaving home. Hmm - maybe not - it's in Chinese only...<\/p>\n<p>I got setup for free at <a href=\"https:\/\/www.noip.com\" target=\"_blank\">www.noip.com<\/a>\u00a0which was instant in giving my IP once the account was input into my router below.<\/p>\n<p>You may also want to setup remote SSH access to the Pi (on a personal port other than 22) so you can stop it, or reboot etc.<\/p>\n<p>If you have an Android phone, put Firefox on from play.google.com and watch the streams.<\/p>\n<p><a href=\"https:\/\/stevepedwards.today\/DebianAdmin\/wp-content\/uploads\/2015\/08\/vigorddns.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-1835\" src=\"https:\/\/stevepedwards.today\/DebianAdmin\/wp-content\/uploads\/2015\/08\/vigorddns.png\" alt=\"vigorddns.png\" width=\"909\" height=\"568\" \/><\/a><\/p>\n<p>16\/8\/15<\/p>\n<p>Other problems with this...<\/p>\n<p>So far this has been testing different options, but one problem I haven't resolved is the timelapse film created gets APPENDED to for successive motion events, so grows to a size that can't be sent!<\/p>\n<p>That's is no good! It needs to create a new video for each new event, to keep you informed, and not be a massive attachment with everything in it.<\/p>\n<p>I've lost interest for now, so stopped the service, but on doing so I also discovered by accident, running tail -f, that sendemail has 47 old messages in its queue! No doubt from mail\/vids it could not send.<\/p>\n<p>$ <span style=\"color: #0000ff;\">tail -f \/var\/log\/syslog<\/span><br \/>\n<span style=\"color: #ff0000;\">Aug 16 13:54:32 pinoir nullmailer[2195]: Starting delivery: protocol: smtp host: mail file: 1439080867.3457<\/span><br \/>\n<span style=\"color: #ff0000;\">Aug 16 13:54:32 pinoir nullmailer[2195]: Starting delivery, 47 message(s) in queue.<\/span><br \/>\n<span style=\"color: #ff0000;\">Aug 16 13:54:34 pinoir nullmailer[3743]: smtp: Failed: Connect failed<\/span><br \/>\n<span style=\"color: #ff0000;\">Aug 16 13:54:34 pinoir nullmailer[2195]: Sending failed: Host not found<\/span><\/p>\n<p>I don't know how to remove these either, except try to uninstall sendemail, which did not stop\u00a0the nullmailer queue.<\/p>\n<p><span style=\"color: #0000ff;\">apt-get remove sendemai<\/span>l<\/p>\n<p>They may be in the mail queue?<\/p>\n<p><span style=\"color: #0000ff;\"> mailq | wc -l<\/span><br \/>\n<span style=\"color: #ff0000;\">94<\/span><\/p>\n<p>Hmm...<\/p>\n<p><span style=\"color: #0000ff;\">man mailq<\/span><\/p>\n<p><span style=\"color: #ff0000;\">INTRODUCTION<\/span><br \/>\n<span style=\"color: #ff0000;\"> nullmailer is a simple and secure relay-only mail transport agent.<\/span><br \/>\n<span style=\"color: #ff0000;\">Documentation on how messages are reformatted and injected into the<\/span><br \/>\n<span style=\"color: #ff0000;\"> queue can be found in nullmailer-inject(1). Documentation on how mes-<\/span><br \/>\n<span style=\"color: #ff0000;\"> sages are actually inserted into the queue can be found in nullmailer-<\/span><br \/>\n<span style=\"color: #ff0000;\"> queue(8). The process of sending queued messages is described in null-<\/span><br \/>\n<span style=\"color: #ff0000;\"> mailer-send(8).<\/span><\/p>\n<p><span style=\"color: #0000ff;\">man\u00a0nullmailer-queue<\/span><\/p>\n<p><span style=\"color: #ff0000;\">OTHER FILES<\/span><br \/>\n<span style=\"color: #ff0000;\"> \/var\/spool\/nullmailer\/queue<\/span><\/p>\n<p><span style=\"color: #0000ff;\"> vi \/var\/spool\/nullmailer\/tmp\/45<\/span><br \/>\n<span style=\"color: #ff0000;\">4549 4551 4552<\/span><\/p>\n<p>Let's remove these \/tmp files:<\/p>\n<p><span style=\"color: #0000ff;\">$ rm -vr --i=no \/var\/spool\/nullmailer\/tmp\/45*<\/span><br \/>\n<span style=\"color: #ff0000;\">removed `\/var\/spool\/nullmailer\/tmp\/4549'<\/span><br \/>\n<span style=\"color: #ff0000;\">removed `\/var\/spool\/nullmailer\/tmp\/4551'<\/span><br \/>\n<span style=\"color: #ff0000;\">removed `\/var\/spool\/nullmailer\/tmp\/4552'<\/span><\/p>\n<p>No - still there:<\/p>\n<p><span style=\"color: #ff0000;\">Aug 16 14:05:56 pinoir nullmailer[2195]: Starting delivery, 47 message(s) in que<\/span><\/p>\n<p><span style=\"color: #0000ff;\">$ rm -vr --i=no \/var\/spool\/nullmailer\/queue\/1439*<\/span><\/p>\n<p>Duh! It's a service, so just stop it:<\/p>\n<p><span style=\"color: #ff0000;\">Aug 16 14:06:58 pinoir nullmailer[2195]: Delivery complete, 47 message(s) remain.<\/span><br \/>\n<span style=\"color: #ff0000;\">Aug 16 14:07:59 pinoir nullmailer[2195]: Rescanning queue.<\/span><br \/>\n<span style=\"color: #ff0000;\">^C<\/span><br \/>\n<span style=\"color: #0000ff;\">$ service nullmailer stop<\/span><br \/>\n<span style=\"color: #ff0000;\">[ ok ] Stopping mail-transfer-agent: nullmailer.<\/span><\/p>\n<p>Tail now shows:<\/p>\n<p><span style=\"color: #ff0000;\">Aug 16 14:09:01 pinoir \/USR\/SBIN\/CRON[4768]: (root) CMD ( \u00a0[ -x \/usr\/lib\/php5\/maxlifetime ] &amp;&amp; [ -x \/usr\/lib\/php5\/<strong>sessionclean<\/strong> ] &amp;&amp; [ -d \/var\/lib\/php5 ] &amp;&amp; \/usr\/lib\/php5\/sessionclean \/var\/lib\/php5 $(\/usr\/lib\/php5\/maxlifetime))<\/span><\/p>\n<p>Hopefully that's stopped it. Remove motion from update-rc for now until I think of something else...or not...<\/p>\n<p>I was looking at <strong><span style=\"color: #0000ff;\">curl<\/span> <\/strong>to send a txt msg instead of sendemail, but it did not work internationally for my phone even though Vodafone UK is listed, via:<\/p>\n<p>DellMint stevee # <span style=\"color: #0000ff;\">curl -X POST <a href=\"https:\/\/textbelt.com\/\" target=\"_blank\">https:\/\/textbelt.com\/<\/a>intl -d number=xxxxxxxxxx<\/span><br \/>\n<span style=\"color: #0000ff;\">d \"message=Dellmint too?\"<\/span><br \/>\n{<br \/>\n<span style=\"color: #ff0000;\">\"success\": true<\/span><\/p>\n<p>17\/8\/15<\/p>\n<p>More info on rollover:<\/p>\n<p><a href=\"https:\/\/www.lavrsen.dk\/foswiki\/bin\/view\/Motion\/MotionGuideBasicFeatures\" target=\"_blank\">https:\/\/www.lavrsen.dk\/foswiki\/bin\/view\/Motion\/MotionGuideBasicFeatures<\/a><\/p>\n<h3><em>ffmpeg_timelapse_mode<\/em><\/h3>\n<ul>\n<li><em>Type: Discrete Strings<\/em><\/li>\n<li><em>Range \/ Valid values: hourly, daily, weekly-sunday, weekly-monday, monthly, manual<\/em><\/li>\n<li><em>Default: daily<\/em><\/li>\n<li><em><a href=\"https:\/\/www.lavrsen.dk\/foswiki\/bin\/view\/Motion\/ConfigOptionFfmpegTimelapseMode\">Option Topic<\/a><\/em><\/li>\n<\/ul>\n<p><em>The file rollover mode of the timelapse video.Note that it is important that you use the conversion specifiers in ffmpeg_filename that ensure that the new timelapse file indeed is a new file. <\/em><\/p>\n<p><em><strong>If the filename does not change Motion will simply append the timelapse pictures to the existing file.<\/strong><\/em><\/p>\n<p><em>The value 'Manual' means that Motion does not automatically rollover to a new filename. You can do it manually using the http control interface by setting the option 'ffmpeg_timelapse' to 0 and then back to your chosen value. Value 'hourly' rolls over on the full hour. Value 'daily' which is the default rolls over at midnight. There are two weekly options because depending on where you come from a week may either start on Sunday or Monday. And 'monthly' naturally rolls over on the 1st of the month.<\/em><\/p>\n<h3><em>gap<\/em><\/h3>\n<ul>\n<li><em>Type: Integer<\/em><\/li>\n<li><em>Range \/ Valid values: 0 - 2147483647<\/em><\/li>\n<li><em>Default: 60<\/em><\/li>\n<li><em><a href=\"https:\/\/www.lavrsen.dk\/foswiki\/bin\/view\/Motion\/ConfigOptionGap\">Option Topic<\/a><\/em><\/li>\n<\/ul>\n<p><em>Gap is the seconds of no motion detection that triggers the end of an event. An event is defined as a series of motion images taken within a short timeframe.Recommended value is 60 seconds (Default). The value 0 is allowed (but not recommended) and disables events causing all Motion to be written to one single mpeg file and no pre_capture. You can force an event to end and a new to begin using the http control 'https:\/\/host:port\/thread_number\/action\/makemovie'. Disabling events has bad side effects on noise_tune and smartmask. Both features can only work properly outside an event. When gap is set to 0, both features don't work properly anymore.An event is defined as a series of motion images taken within a short timeframe. E.g. a person walking through the room is an event that may have caused 10 single jpg images to be stored. This option defines how long a pause between detected motions that is needed to be defined as a new event.The gap timer starts after the last motion is detected and post_capture images have been saved and appended to open movie mpeg files.Any motion detected before the gap timer times out resets the gap timer so it starts counting over again.<\/em><\/p>\n<p><em><strong>Detailed Description<\/strong><\/em><\/p>\n<p><em>The option 'gap' is important. It defines how long a period of no motion detected it takes before we say an event is over. An event is defined as a series of motion images taken within a short timeframe. E.g. a person walking through the room is an event that may have caused 10 single jpg images to be stored. Motion detected includes post_captured frames set by the 'post_capture' option. The 'gap' option defines how long a pause between detected motions that is needed to be defined as a new event. A good starting value is 60 seconds.The way 'gap' works in more technical terms is:<\/em><\/p>\n<ul>\n<li><em>Gap is a timer that timeout 'gap' seconds after the last video frame with motion is detected.<\/em><\/li>\n<li><em>If 'post_capture' is activated then the gap timer starts counting after the last image of the post_capture buffer has been saved.<\/em><\/li>\n<li><em>The gap timer is reset and starts all over each time new motion is detected, so you will not miss any action by having a short 'gap' value. It will just create more events (e.g. more mpegs files)<\/em><\/li>\n<\/ul>\n<p><em>The gap value impacts many functions in Motion.<\/em><\/p>\n<ul>\n<li><strong><em>When the gap timer runs out the event number is increased by one next time motion is detected. When you use the %v conversion specifier in filenames or text features this means that the number in filename or text increased by one.<\/em><\/strong><\/li>\n<li><strong><em>The pre_capture feature only works at the beginning of an event. So if you have a very large 'gap' value pre_capture is not working very often.<\/em><\/strong><\/li>\n<li><strong><em>When you make mpegs using the ffmpeg features, a new mpeg file is started at the beginning of an event when the first motion is detected. When 'gap' seconds has passed without motion (and post_captured frames saved) the mpeg files is completed and closed.<\/em><\/strong><\/li>\n<li><strong><em>Do not use large gap values to generate one large mpeg4 file. If Motion stops working this mpeg4 file never gets properly completed and closed and you will not be able to view it.<\/em><\/strong><\/li>\n<li><strong><em>Some of the tracking features sets the camera back to the center position when an event is over.<\/em><\/strong><\/li>\n<\/ul>\n<p><em>Note that 'gap' and 'minimum_gap' have nothing to do with each other.<\/em><\/p>\n<p>I am just trying a shorter gap time between events, and a max movie size of 10 minutes - this will probably generate a lot more emails, but at the mo its sending me 1 x 15MB file!:<\/p>\n<p><span style=\"color: #ff0000;\"># Recommended value is 60 seconds (Default). The value 0 is allowed and disables<\/span><br \/>\n<span style=\"color: #ff0000;\"># events causing all Motion to be written to one single mpeg file and no pre_capture.<\/span><br \/>\n<span style=\"color: #ff0000;\">gap 30<\/span><\/p>\n<p><span style=\"color: #ff0000;\"># Maximum length in seconds of an mpeg movie<\/span><br \/>\n<span style=\"color: #ff0000;\"># When value is exceeded a new mpeg file is created. (Default: 0 = infinite)<\/span><br \/>\n<span style=\"color: #ff0000;\">max_mpeg_time 600<\/span><\/p>\n<p>Just to try to prevent 1 frame bird shadows being a trigger, let's not get ALL motion:<\/p>\n<p><span style=\"color: #ff0000;\"># Picture frames must contain motion at least the specified number of frames<\/span><br \/>\n<span style=\"color: #ff0000;\"># in a row before they are detected as true motion. <strong>At the default of 1, all<\/strong><\/span><br \/>\n<span style=\"color: #ff0000;\"><strong># motion is detected.<\/strong> Valid range: 1 to thousands, recommended 1-5<\/span><br \/>\n<span style=\"color: #ff0000;\">minimum_motion_frames 3<\/span><\/p>\n<p>You may want to reboot for a \"lost\" camera:<\/p>\n<p><span style=\"color: #ff0000;\"># Command to be executed when a camera can't be opened or if it is lost<\/span><br \/>\n<span style=\"color: #ff0000;\"># NOTE: There is situations when motion doesn't detect a lost camera!<\/span><br \/>\n<span style=\"color: #ff0000;\"># It depends on the driver, some drivers don't detect a lost camera at all<\/span><br \/>\n<span style=\"color: #ff0000;\"># Some hang the motion thread. Some even hang the PC! (default: none)<\/span><br \/>\n<strong><span style=\"color: #ff0000;\"> on_camera_lost reboot<\/span><\/strong><\/p>\n<p>Later...<\/p>\n<p>Those changes did nothing to the appended timelapse, but it looks like the name is missing the event trigger, %v, in the conf file, so adding that may cause a new film for each consecutive event? \u00a0I'll try and retest, with the Hour added also.<\/p>\n<p><span style=\"color: #ff0000;\"># File path for timelapse mpegs relative to target_dir<\/span><br \/>\n<span style=\"color: #ff0000;\"># Default: %Y%m%d-timelapse<\/span><br \/>\n<span style=\"color: #ff0000;\"># Default value is near equivalent to legacy oldlayout option<\/span><br \/>\n<span style=\"color: #ff0000;\"># For Motion 3.0 compatible mode choose: %Y\/%m\/%d-timelapse<\/span><br \/>\n<span style=\"color: #ff0000;\"># File extension .mpg is automatically added so do not include this<\/span><br \/>\n<span style=\"color: #ff0000;\">timelapse_filename <strong>%v<\/strong>-%Y%m%d%H-timelapse<\/span><\/p>\n<p>Also, I want the date in reverse order - easier to read:<\/p>\n<p><span style=\"color: #ff0000;\"># External Commands, Warnings and Logging:<\/span><br \/>\n<span style=\"color: #ff0000;\"># You can use conversion specifiers for the on_xxxx commands<\/span><br \/>\n<span style=\"color: #ff0000;\"># %Y = year, %m = month, %d = date,<\/span><br \/>\n<span style=\"color: #ff0000;\"># %H = hour, %M = minute, %S = second,<\/span><br \/>\n<span style=\"color: #ff0000;\"># %v = event, %q = frame number, %t = thread (camera) number,<\/span><br \/>\n<span style=\"color: #ff0000;\"># %D = changed pixels, %N = noise level,<\/span><br \/>\n<span style=\"color: #ff0000;\"># %i and %J = width and height of motion area,<\/span><br \/>\n<span style=\"color: #ff0000;\"># %K and %L = X and Y coordinates of motion center<\/span><br \/>\n<span style=\"color: #ff0000;\"># %C = value defined by text_event<\/span><br \/>\n<span style=\"color: #ff0000;\"># %f = filename with full path<\/span><br \/>\n<span style=\"color: #ff0000;\"># %n = number indicating filetype<\/span><br \/>\n<span style=\"color: #ff0000;\"># Both %f and %n are only defined for on_picture_save,<\/span><br \/>\n<span style=\"color: #ff0000;\"># on_movie_start and on_movie_end<\/span><br \/>\n<span style=\"color: #ff0000;\"># Quotation marks round string are allowed.<\/span><\/p>\n<p>So,\u00a0<strong>%v<\/strong>-%Y%m%d%H-timelapse, becomes:<\/p>\n<p><span style=\"color: #ff0000;\"><strong>%v<\/strong>-%H%d%m%Y-timelapse<\/span><\/p>\n<p>or this sort of format for easy reading:<\/p>\n<p>timelapse_filename %v-%Hhr%Mmin_%d_%m_%Y-timelapse<\/p>\n<p>which gives the name:<\/p>\n<p>01-18hr08mins_17_08_2015-timelapse.mpg<\/p>\n<p>or - (but not a wise filename for Linux):<\/p>\n<p><em><span style=\"color: #ff0000;\"># You can put quotation marks around the text to allow<\/span><\/em><br \/>\n<em><span style=\"color: #ff0000;\"># leading spaces<\/span><\/em><\/p>\n<p>OK - you cannot have multi - timelapse movies as separate event summaries by its nature! it's not for that. You always get an appended file.<\/p>\n<h3>ffmpeg_timelapse<\/h3>\n<ul>\n<li>Type: Boolean<\/li>\n<li>Range \/ Valid values: 0 - 2147483647<\/li>\n<li>Default: 0 (disabled)<\/li>\n<li><a class=\"foswikiCurrentTopicLink\" href=\"https:\/\/www.lavrsen.dk\/foswiki\/bin\/view\/Motion\/ConfigOptionFfmpegTimelapse\">Option Topic<\/a><\/li>\n<\/ul>\n<p><em><strong>[2147483647 is (2^32\/2) -1, to account for the 0 between +ve and -ve 32 bit numbers]<\/strong><\/em><\/p>\n<p><a href=\"https:\/\/www.lavrsen.dk\/foswiki\/bin\/view\/Motion\/ConfigOptionFfmpegTimelapse\" target=\"_blank\">https:\/\/www.lavrsen.dk\/foswiki\/bin\/view\/Motion\/ConfigOptionFfmpegTimelapse<\/a><\/p>\n<p><em>Create a timelapse movie saving a picture frame at the interval in seconds set by this parameter. Set it to 0 if not used.This feature uses ffmpegs libavcodec to encode a timelapse movie saving a picture frame at the interval in seconds set by this parameter. Setting this option to 0 disables it.The feature gives your viewer the chance to watch the day pass by. It makes a nice effect to film flowers etc closeup during the day. Options like frame_rate, snapshot, gap etc have no impact on the ffmpeg timelapse function.Note that the timelapse format is always mpeg1 independent of ffmpeg_video_codec. This is because mpeg1 allows the timelapse to stop and the file to be reopened and more film appended.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_1805\" class=\"pvc_stats all  \" data-element-id=\"1805\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/stevepedwards.today\/DebianAdmin\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n<p>After studying the conf file for Motion looking for an Email Alert function of some kind, I found: # Command to be executed when an event starts. (default: none) # An event starts at first motion detected after a period of no motion defined by gap ; on_event_start value I thought about using sendemail as <a href=\"https:\/\/stevepedwards.today\/DebianAdmin\/using-sendemail-curl-for-a-motion-alert-and-hacking-its-2-year-old-perl-tls-bug\/\" class=\"more-link\">...<span class=\"screen-reader-text\">\u00a0 Using Sendemail + Curl For a Motion Alert and Hacking Its 2+ year old Perl TLS Bug<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-1805","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"a3_pvc":{"activated":true,"total_views":10,"today_views":0},"_links":{"self":[{"href":"https:\/\/stevepedwards.today\/DebianAdmin\/wp-json\/wp\/v2\/posts\/1805","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/stevepedwards.today\/DebianAdmin\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/stevepedwards.today\/DebianAdmin\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/stevepedwards.today\/DebianAdmin\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/stevepedwards.today\/DebianAdmin\/wp-json\/wp\/v2\/comments?post=1805"}],"version-history":[{"count":1,"href":"https:\/\/stevepedwards.today\/DebianAdmin\/wp-json\/wp\/v2\/posts\/1805\/revisions"}],"predecessor-version":[{"id":10563,"href":"https:\/\/stevepedwards.today\/DebianAdmin\/wp-json\/wp\/v2\/posts\/1805\/revisions\/10563"}],"wp:attachment":[{"href":"https:\/\/stevepedwards.today\/DebianAdmin\/wp-json\/wp\/v2\/media?parent=1805"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/stevepedwards.today\/DebianAdmin\/wp-json\/wp\/v2\/categories?post=1805"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/stevepedwards.today\/DebianAdmin\/wp-json\/wp\/v2\/tags?post=1805"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}