blob: 7d0dc4c644ab4fd13f36cadd48631140ee3275ea (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
#!/bin/bash -
# SJP August 2014
# Reads logfile of IP address records created by monitor.sh
# When IP address changes it sends an email"
cd ~/mail/monitor
if (test -e data/tmp.*) then
datafile=$(ls data/tmp.*)
else
exit
fi
# read a whole file line by line
#i=0
#while read line
#do
# i=$[i+1]
# echo $i, $line
#done < $datafile
# Get the IP address from the first line
read firstline < $datafile
firstip=$(echo $firstline | awk '{ print $2 }')
# sec=$(echo $firstline | awk '{ print $1 }')
echo "First = $firstip"
lastline=$(tail -1 $datafile)
lastip=$(echo $lastline | awk '{ print $2 }')
echo "Last = $lastip"
[ "$lastip" == "$firstip" ] && echo 'match' || echo 'different'
|