#!/bin/sh # # idea & code by Deniss (deniss@fuckoff.com ) C2003 # FILEWITHPASS=/home/pass/bin/webpassfile LENGTH=5 ADMIN="admin@mydomain.com\n" GREP=/usr/bin/egrep CUT=/usr/bin/cut CAT=/bin/cat MAIL=/bin/mail DATE=`/usr/bin/date +'%Y.g. %d.%m'` MAILTO=`${CAT} | ${GREP} '^From\:' | ${GREP} -o '([a-zA-Z0-9_]|\\-|\\.)+@[a-z\.]*mydomain\.com' \ | ${GREP} -o '^([a-zA-Z0-9_]|\\-|\\.)+@[a-z\.]*mydomain\.com' | ${GREP} -vi 'pass' \ | ${GREP} -vi 'mailer-daemon'` if [ -x ${MAILTO} ]; then exit; fi if [ -s ${FILEWITHPASS} ]; then { CURRENT=`head --lines=1 ${FILEWITHPASS}` CURRENT=`echo ${CURRENT} | ${GREP} -o -E '[a-zA-Z0-9]+' | ${CUT} -c 0-${LENGTH}` NEXT=`tail --lines=1 ${FILEWITHPASS}` NEXT=`echo ${NEXT} | ${GREP} -o -E '[a-zA-Z0-9]+' | ${CUT} -c 0-${LENGTH}` if [ x${CURRENT} == x${NEXT} ]; then { NEXT='' }; fi }; else { exit; }; fi MSG=" Hello,\n Current password is ${CURRENT}\n Next password will be ${NEXT}\n\n For furthermore info plz contact:\n ${ADMIN}\n\n " echo -e ${MSG} | ${MAIL} -s "This is password announcer" ${MAILTO} #eof