Saffik
Posts: 17
Joined: Mon Jan 12, 2015 11:34 am

RPI sendEmail doesn't work, help!

Thu Feb 12, 2015 8:57 pm

Hello all.

So I've got a firmware on my raspberry pi which have been developed by someone and the OS is based on BuildRoot and uses motion as a backend.

So, basically I'm trying to set up a script that will email me the external IP address of the rpi everytime it changes.

The scripts I'm using are:
1.sendip

Code: Select all

#!/bin/bash

source /etc/sendip.conf

if [[ -z $1 ]]
then
    echo "
Usage: $0 <email address> 
"
    exit 1
fi

EMAIL_ADDRESS=$1

expand_message ()
{
    echo "$1" | while read LINE
    do
        echo "$(eval echo $LINE)"
    done
}

if [[ -f "/tmp/.ipaddress" ]]
then
    OLDIP=$(cat /tmp/.ipaddress)
fi

NEWIP=$(wget -qO - http://what-is-my-ip.net/?text)

if [[ "$OLDIP" != "$NEWIP" ]]
then
    MESSAGE=$(expand_message "$EMAIL_MESSAGE")

    sendEmail -f $RASPBERRY_EMAIL -t $EMAIL_ADDRESS -s $SMTP_HOST -u $EMAIL_SUBJECT -xu $RASPBERRY_EMAIL -xp $RASPBERRY_PASSWORD -m "$MESSAGE" -o tls=yes
    echo $NEWIP > /tmp/.ipaddress
fi
2. sendip.conf

Code: Select all

# sendip config file

# SMTP Server address with port, default port is 25
SMTP_HOST="smtp.gmail.com:587"

# new IP Email subject 
EMAIL_SUBJECT="My new IP address"

# Raspberry Pi Email address, email will be send out using
# this email address
RASPBERRY_EMAIL="myEmail@gmail.com"

# Password for above email address
RASPBERRY_PASSWORD="myPassword"

EMAIL_MESSAGE='
Hello,

My new IP address is $NEWIP.

Regards,
Raspberry Pi

'
It also uses sendEmail command line tool, which is written in Perl and available in Rasbian repositories.
This uses a perl file under /data/etc/perl.
The top line of sendEmail script is like:

Code: Select all

#!/usr/bin/perl -w
So everytime I execute my script by entering:
./sendip myGoogleMail@gmail.com

It returns with:
./sendip: /data/etc/sendEmail: /usr/bin/perl: bad interpreter: No such file or directory


.... any ideas?

Also, I can't install any packages onto my rpi as it wont recognise the commands. (Anyway this is not my issue. My main problem is that it's throwing the interpreter error above)

Code: Select all

[root@mypi ]sudo apt-get install build-essential libssl-dev sendemail curl
Returns: -sh: apt-get: command not found

[root@mypi ]sudo cpan install IO::Socket::SSL
Returns: -sh: cpan: command not found
Last edited by Saffik on Thu Feb 12, 2015 10:04 pm, edited 1 time in total.

User avatar
jimmyeao
Posts: 27
Joined: Wed Jun 27, 2012 7:34 am
Location: Lincoln, Lincolnshire LN6 7QY, UK
Contact: Website

Re: RPI sendEmail doesn't work, help!

Thu Feb 12, 2015 9:53 pm

it sounds like the distro you are using doesn't support apt-get or aptitude.

What flavour of Linux is it? Any particular reason you arent using Raspbian?
Follow my Raspberry Pi experience at www.deviousweb.com

Saffik
Posts: 17
Joined: Mon Jan 12, 2015 11:34 am

Re: RPI sendEmail doesn't work, help!

Thu Feb 12, 2015 9:56 pm

Yes, actually I'm not using raspbian. This works perfect in Raspbian, but I'm using a new OS/firmware that has been designed to create a home made CCTV system. It is based on BuildRoot and therefore all the commands that work in Raspbian won't work here. :(

cat /etc/*-release
NAME=Buildroot
VERSION=2014.11-g3f1f13a-dirty
ID=buildroot
VERSION_ID=2014.11
PRETTY_NAME="Buildroot 2014.11"
jimmyeao wrote:it sounds like the distro you are using doesn't support apt-get or aptitude.

What flavour of Linux is it? Any particular reason you arent using Raspbian?

User avatar
B.Goode
Posts: 8987
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: RPI sendEmail doesn't work, help!

Thu Feb 12, 2015 10:12 pm

Saffik wrote:Yes, actually I'm not using raspbian. This works perfect in Raspbian, but I'm using a new OS/firmware that has been designed to create a home made CCTV system. It is based on BuildRoot and therefore all the commands that work in Raspbian won't work here.
If you have a 'custom' Operating System it seems to me that your source of advice should be the person or company who put that system together - noone else can possibly know for sure how it is built or configured, or how to modify it.

Return to “Troubleshooting”