1

This question has been asked before in various ways but either the answers does not seem to work or some advanced code that's complicated to me anyway so I have tried to achieve my own. That hopefully for the less experienced is easier to follow

using a siple bash script and ctontab

date >> /home/pi/Myideas/energy/ipaddrs.txt

the above line gets the date and time and appends it to the txt file

wget -q -O - checkip.icanhazip.com | grep -Po "[\d\.]+" >> ipaddrs.txt

the above line gets my external ip address and apends it to the same txt file

this file is emailed with a python script every day

so the txt file will populate as follows

date time
88.89.90.100

date time
88.89.90.100

date time
88.89.90.100

date time
88.89.90.100

date time
88.89.90.101

how can I search the txt file to compare the last and 3rd from last entries ie the last 2 IP address so when there is a difference it triggers my python email script

thanks for any help

Aja
  • 23
  • 9

0 Answers0