summaryrefslogtreecommitdiff
path: root/compare.sh
diff options
context:
space:
mode:
authorF3RR3T <github@st33v.com>2014-08-24 14:26:51 +1000
committerF3RR3T <github@st33v.com>2014-08-24 14:26:51 +1000
commit064edd67e0535f01a98282505e34ce02eb03befa (patch)
tree1a11a016c7c55421c4e18a5ce49cf158af59b2dd /compare.sh
parent1ed1f885f7dce63b62289260ad4fd48679c60e98 (diff)
Interim stage.
Monitor script logs every 30 mins. compare.sh has some test file reading and comparison functions But the time has come to wrap it all into one script. This will be called monitor.sh
Diffstat (limited to 'compare.sh')
-rwxr-xr-xcompare.sh38
1 files changed, 38 insertions, 0 deletions
diff --git a/compare.sh b/compare.sh
new file mode 100755
index 0000000..1db6a21
--- /dev/null
+++ b/compare.sh
@@ -0,0 +1,38 @@
+#!/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
+
+
+#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'