/ Published in: Bash
Simple whois monitor by text file DB. Compares filesizes to exclude unimportant difference like current date in output.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#!/bin/sh # Copyright (c) 2010 Mihail Fedorov, http://mihailfedorov.ru # $ ./whois2.sh # DB file format: # domain.ru|whois.ripn.net|[email protected]| # domain.tel|whois.nic.tel|[email protected]| # change this WORKDIR="/home/kolo/bots/whois" FILE="/home/kolo/bots/whois.db.txt" FS="|" # thanks while read line do # warZ DOMAIN=$(echo $line|cut -d$FS -f1) SERVER=$(echo $line|cut -d$FS -f2) MAIL=$(echo $line|cut -d$FS -f3) TEXTBEFORE="/home/kolo/bots/before.txt" TEXTAFTER="/home/kolo/bots/after.txt" NEWFILE="$WORKDIR/$DOMAIN.$SERVER.$MAIL" OLDFILE="$WORKDIR/$DOMAIN.$SERVER.$MAIL.old" touch $NEWFILE mv $NEWFILE $OLDFILE 2> /dev/null whois -H -h $SERVER $DOMAIN > $NEWFILE 2> /dev/null oldsize=$(stat -c %s "$OLDFILE" 2> /dev/null) newsize=$(stat -c %s "$NEWFILE") if [ "$oldsize" != "$newsize" ] && [ -s $NEWFILE ] ; then cat $TEXTBEFORE $OLDFILE $TEXTAFTER $NEWFILE > /tmp/whois.txt cat /tmp/whois.txt | mail -s "[Whois2] $DOMAIN updated" $MAIL # here comes also notifying via Nabaztag API. # you don't need this ;) # but you can add SMS/Jabber/ICQ else mv $OLDFILE $NEWFILE 2> /dev/null fi done < $FILE