Instantly share code, notes, and snippets.

Embed
What would you like to do?
Emails the position of your ranking on blitzortung.org every time it changes
#!/bin/bash
email=$1
epc=$(date +%s)
echo $epc
# Country does not seem to be important
res=$(curl --data "info_time=$epc&info_email=$email&info_country=United+Kingdom&info_text=TSqrb" http://en.blitzortung.org/cover_your_area.php)
#echo "-----------------------------"
#echo "HTML Response"
#echo $res
#echo "-----------------------------"
html=$(echo "$res" | grep $email)
#echo "-----------------------------"
#echo "Position Text"
#echo $html
#echo "-----------------------------"
textpositionstart=411+${#email}+1
echo "textpositionstart: $textpositionstart"
position=${html:$textpositionstart:6}
position=$(echo $position | sed 's@^[^0-9]*\([0-9]\+\).*@\1@')
echo "position: $position"
lastpositionfilename=blitzortung-last-position.txt
lastposition=$(cat $lastpositionfilename)
catresult=$?
echo "catresult $catresult"
if [ "$catresult" -eq "1" ]; then
echo "didn't find last position file"
lastposition=100000
else
echo "found last position file"
fi
echo "lastposition: $lastposition"
if [ "$position" -lt "$lastposition" ]; then
echo $position | mail -s "blitzortung.org position" $email
echo $position > $lastpositionfilename
else
echo "position not less than $lastposition: $position"
fi
exit
@vls29

This comment has been minimized.

Show comment
Hide comment
@vls29

vls29 Dec 26, 2017

Requires mailutils - or replace the mail section with your favourite package as required.

Give the script executable permission and then you can call the script like ./blitzortung-position.sh [REPLACE WITH EMAIL USED TO SIGN UP ON BLITZORTUNG.ORG]

I have the script hardcoded with my email address and the script on a daily cron to send me any changes in position.

Owner

vls29 commented Dec 26, 2017

Requires mailutils - or replace the mail section with your favourite package as required.

Give the script executable permission and then you can call the script like ./blitzortung-position.sh [REPLACE WITH EMAIL USED TO SIGN UP ON BLITZORTUNG.ORG]

I have the script hardcoded with my email address and the script on a daily cron to send me any changes in position.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment