#!/bin/bash

NAME=""
DETAILS=""
TMPFILE="/tmp/invsuche"

NUMMER=`echo $1 | sed -e "s/\ //g" -e "s/+49/0/"`

if [ "$NAME" == "" ]; then
#    echo "Suche nach $NUMMER in [URL]www.dasoertliche.de[/URL]"
    lynx "http://www.dasoertliche.de/DB4Web/es/oetb2suche/home.htm?kw_invers=$NUMMER&main=Antwort&s=2" \
        -dump -nolist -connect_timeout=3>  $TMPFILE

    NAME=`grep printselected.gif -A 2 $TMPFILE | awk '{ if (FNR == 2) print $0 }' |  sed  -e "s/\ \+//" -e "s/\ \+/\ /g" -e "s/\[_\]//g"`
    DETAILS=`grep printselected.gif -A 2 $TMPFILE | awk '{ if (FNR == 3) print $0 }' |  sed  -e "s/\ \+//" -e "s/\ \+/\ /g" -e "s/\[_\]//g"`


fi

rm $TMPFILE

echo "$NUMMER $NAME $DETAILS" > $2
