#!/bin/bash

grep 'IP:' list_users.dat | awk '{print $2}' >IP.dat
cat IP.dat | sort -k1n,1n >IP_tri
#supprime les doublons
awk '!a[$0]{a[$0]++;print}' IP_tri >IP_OK

touch all
rm all
touch all

for ip in `awk '{print $1}' IP_OK` ; do
    echo "wget http://xml.utrace.de/?query=${ip}"
    wget http://xml.utrace.de/?query=${ip}
    sleep 3
    cat index.html* all >toto
    mv toto all
    rm index.html*
done


grep '<ip>' all >ip
grep '<latitude>' all >lat
grep '<longitude>' all >lon

paste ip lat lon >COORD

cat COORD | sed "s|latitude||g" \
          | sed "s|ip||g" \
          | sed "s|longitude||g" \
          | sed "s|</||g" \
          | sed "s|<||g" \
          | sed "s|>||g" >COORD_clean


