#!/bin/bash
# export http_proxy=http://wr-linux01.rki.ivbb.bund.de:3128/
# export http_proxy=http://wittenau.ivbb.bund.de:80/
export LANGUAGE="de_DE:de:en_GB:en"
export LANG="de_DE.UTF-8"

source /etc/local/profile.local > /dev/null

touch ~/tmp/gl-links.new
touch ~/tmp/gl-links.old
[ -s ~/tmp/gl-links.old ] && cp -a ~/tmp/gl-links.old ~/tmp/gl-links.old2
[ -s ~/tmp/gl-links.new ] && mv ~/tmp/gl-links.new ~/tmp/gl-links.old

# lynx -dump http://www.golem.de/aa.html |
lynx -dump http://www.golem.de/htmlheadlines.htm | \
     grep http.*www.golem.de/[0-9]*/[0-9]*.html | \
     cut -c 7- >  ~/tmp/gl-links.new

#echo start1

cat ~/tmp/gl-links.new ~/tmp/gl-links.old ~/tmp/gl-links.old ~/tmp/gl-links.old2 ~/tmp/gl-links.old2 |sort|uniq -u|while read a
do
	# echo $a
	w3m -dump_source "$a" | zgrep ".*" | ~/bin/golem.pl > /tmp/gl_$$.html
	# echo 1
	w3m -dump /tmp/gl_$$.html > /tmp/gl_$$.txt
	# echo 2
	(echo $a; echo ; cat /tmp/gl_$$.txt)| mailx -a "Content-Type: TEXT/PLAIN; charset=UTF-8; format=flowed" -s "GL: `head -1 /tmp/gl_$$.txt`" tillea@localhost
	# echo 3
	rm /tmp/gl_$$.html /tmp/gl_$$.txt
	# echo 4
done
