#!/bin/sh
TDIR=/tmp
FILEx=$HOME/bin/long
FILE1=$HOME/faelligkeitx-`date +%d-%m-%y`.txt
FILE3=$HOME/lynx_bookmarks.html
LOCK=$HOME/.lock
if [ $# -gt 0 ]; then
	echo "usage: "`basename $0`
	exit 1
fi
if [ -e $LOCK ]; then
	echo locked.
else
	cd $TDIR
	an.sh $FILEx kurs > $FILE1
	chmod 700 $FILE1
	$FILE1
	for a in `awk '{print $1}' $FILEx`
	do
		grep -m 2 -A 1 lligkeit $a.kurs | grep -v '\--' | \
		sed '$!N;s/\n/ /' | grep -v Rendite | \
		awk '{ORS=" ";print $2}' > $FILE1
		if [ `grep "n.a" $FILE1 | wc -w` = 1 ]; then
			echo -n "n.a.perpetual " > $FILE1
		fi
		if  [ `grep -c $a $FILE3` = 1 ]; then
			getname.sh $a >> $FILE1
		fi
		echo -n $a" "
		cat $FILE1
		echo ""
		rm $FILE1 $a.kurs
	done
fi
