jasmeu
Posts: 14
Joined: Sun Mar 17, 2013 5:26 pm

Surveillance WebCam in the Cloud

Sun Mar 17, 2013 5:48 pm

I entered a first blog on implementing a Surveillance WebCam in the Cloud here:
http://www.jasm.eu/2013/03/17/raspberry ... the-cloud/
I thought to share this with everyone, as I myself also learned a lot from this forum.



PigNib
Posts: 1
Joined: Sat May 04, 2013 12:10 am

Re: Surveillance WebCam in the Cloud

Sat May 04, 2013 12:16 am

Question about the email parser...

I'm running fetchmail -v manually to get debug as I am not receiving the help email..

I'm getting this:

<snip>
fetchmail: IMAP< )
fetchmail: IMAP< A0007 OK Success
fetchmail: IMAP> A0008 FETCH 2 BODY.PEEK[TEXT]
/home/pi/dev/mailParse/parser.sh: line 50: syntax error: unexpected end of file
fetchmail: IMAP< * 2 FETCH (BODY[TEXT] {230}
(230 body octets) ***********
fetchmail: IMAP< )
fetchmail: IMAP< A0008 OK Success
fetchmail: Error writing to MDA: Broken pipe
not flushed
<snip>


I'm not much of a coder but a couple of questions:
1) There isn't a closing } for your sendmail function
2) At the end of the script there are two 'fi' in a row... was this intentional?

Thanks in advance!



[email protected] ~/dev/mailParse $ vi ~/dev/mailParse/parser.sh
#!/bin/bash
expectedFrom="[email protected]"
expectedFrom2="[email protected]"

mailHelp() {
sendMail $1 "Help - Possible Commands" "Help"
}

sendMail() {
tmpMail="/var/tmp/mailtxt.txt"
echo "To: "$1 > $tmpMail
echo "From: [email protected]" >> $tmpMail
echo "Subject: "$2 >> $tmpMail
echo "" >> $tmpMail
echo $3 >> $tmpMail
/usr/sbin/ssmtp $1 $tmpFile
while read x
do
echo $x >> $tmpFile
done
#here we start the actual processing

rightSender=0
sender=""

grep "From:" $tmpFile | grep $expectedFrom > /dev/null
if [ $? -eq 0 ]; then
rightSender=1
sender=$expectedFrom
fi

grep "From:" $tmpFile | grep $expectedFrom2 > /dev/null
if [ $? -eq 0 ]; then
rightSender=1
sender=$expectedFrom2
fi

if [ $rightSender -eq 1 ]; then
task=`grep "Subject:" $tmpFile`
task=${task:9}
task=`echo $task | tr [:upper:] [:lower:]`

echo $task | grep "help" > /dev/null
if [ $? -eq 0 ]; then
mailHelp $sender
fi

fi
rm $tmpFile

jasmeu
Posts: 14
Joined: Sun Mar 17, 2013 5:26 pm

Re: Surveillance WebCam in the Cloud

Sun May 05, 2013 9:09 am

1. Right now I'm not next to my PI, so I cannot cross check the source; But you could be right; Try to add a } at the end of the script, after "rm $tmpFile". I probably have to find a better way to paste code into the Wordpress blog, as sometimes some characters get lost during copy / paste.
2. Yes, I think the 2 fi are fine; One if for checking for "help" in the subject and the other one is for the "if [ $rightSender -eq 1 ]; then" above. (Indentation is another aspect which gets lost during copy / paste, and the code is thus less readable)

sesam
Posts: 16
Joined: Sun Apr 28, 2013 7:45 pm

Re: Surveillance WebCam in the Cloud

Sun May 05, 2013 12:06 pm

I'm also getting the

Code: Select all

fetchmail: Error writing to MDA: Broken pipe
 not flushed
Even if I comment everything inside the parser.sh
I am trying to understand what the MDA "needs" at minimum to work.

jasmeu
Posts: 14
Joined: Sun Mar 17, 2013 5:26 pm

Re: Surveillance WebCam in the Cloud

Tue May 14, 2013 10:14 pm

@pignib: Ok now ?
@sesam: the point with the missing } could be relevant for the issue you mentioned, too.


fotastisch
Posts: 35
Joined: Tue Aug 07, 2012 4:37 pm

Re: Surveillance WebCam in the Cloud

Thu May 30, 2013 9:14 pm

Hey!

I'm also having trouble with the "Broken Pipe". I copied the code from the article and added the "}".
This is the error I get:

Code: Select all

1 message for [email protected] at imap.xxxxx.com (folder INBOX).
fetchmail: Error writing to MDA: Broken pipe
reading message [email protected]@imap.xxxxx.com:1 of 1 (3124 header octets) (2 body octets) not flushed
Have you already found a fix?

Thank you very much!

jasmeu
Posts: 14
Joined: Sun Mar 17, 2013 5:26 pm

Re: Surveillance WebCam in the Cloud

Mon Jun 03, 2013 8:50 pm

I adjusted the known page and hopefully no < or > got lost through copy / paste anymore.
Please post an answer here should this still not work fine.

fotastisch
Posts: 35
Joined: Tue Aug 07, 2012 4:37 pm

Re: Surveillance WebCam in the Cloud

Wed Jun 05, 2013 8:34 am

Hey!

Thanks, that did the trick ;)

jasmeu
Posts: 14
Joined: Sun Mar 17, 2013 5:26 pm

Re: Surveillance WebCam in the Cloud

Wed Jun 05, 2013 7:50 pm

Great ! Enjoy ! :)

sbprojects
Posts: 1
Joined: Fri Jun 14, 2013 9:55 am

Re: Surveillance WebCam in the Cloud

Fri Jun 14, 2013 10:07 am

I like your webcam scripts. Have to get myself a webcam soon and start experimenting with it. Would be fun if I got an email with the picture of the people ringing my door bell when I'm not at home.

You took a whole lot of trouble creating an application to upload to Dropbox. I'm a great Dropbox fan myself. But for Raspberry Pi cloud storage I use the webdav protocol in combination with a 5 GB free http://www.box.com account.
If you are interested in how I've solved cloud storage please visit http://www.sbprojects.com/projects/rasp ... webdav.php

And a promising new Dropbox like service is http://www.copy.com. They offer 20 GB of free cloud storage if you sign up using this link: https://copy.com/?r=3rv4cR . They've told me they will support webdav in the near future too.
Keep up the good work.

jasmeu
Posts: 14
Joined: Sun Mar 17, 2013 5:26 pm

Re: Surveillance WebCam in the Cloud

Mon Jul 22, 2013 9:55 pm

Thank you @sbprojects for the hint;

And an update to my Surveillance WebCam in the Cloud:
Several improvements I did to make it more stable: http://www.jasm.eu/2013/07/22/raspberry ... rovements/

Return to “Graphics, sound and multimedia”