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
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
'
This uses a perl file under /data/etc/perl.
The top line of sendEmail script is like:
Code: Select all
#!/usr/bin/perl -w
./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