#!/bin/sh

# Small script to lookup a key on a keyserver
#
# (c) 2000 by Christian Kurz <shorty@debian.org>, 
#             Peter Palfrader <ppalfrad@cosy.sbg.ac.at>
#
#  Distribution, usage etc. pp. regulated by the current version of GPL.

NC=`which nc`

if [ "$NC" = "" ]; then
   echo "stop: netcat (nc) not installed" >&2
   exit 1
fi
  


if [ -z "$2" ]; then
	echo "usage: `basename $0` '<name> '"
	echo -e "name must be a first and lastname"
	exit 0
fi

echo -e "\n"
echo "Public Key Server Answer for $1 $2"

KEYSERVER=wwwkeys.de.pgp.net
OUTPUT=keys.html
NAME1=$1
NAME2=$2

(
	echo 'GET /pks/lookup?op=index&search='$1'+'$2
	echo 
) | $NC $KEYSERVER 11371 \
  | egrep -v "html|Copyright|HTTP|Content-type" \
  | sed 's/<[^>]*>//g; s/&lt;/</g; s/&gt;/>/g; s/&quot;/"/g; s/&amp;/&/g;' \
  | egrep -v "Public Key Server"