#!/bin/tcsh

setenv theLinkNum `echo "${1}" | sum | cut -f1 -d' '`
echo ${1}
echo $theLinkNum

if ( -f $theLinkNum.info ) then
	echo $theLinkNum already exists, time to make real code.
	exit
endif

/usr/local/bin/lynx -source "${1}" | head -40 | tr '<' '\n' | grep -i '^title>' | head -1 | cut -f2 -d'>' | cut -f1 -d'<'  
/usr/local/bin/lynx -source "${1}" | head -40 | tr '<' '\n' | grep -i '^title>' | head -1 | cut -f2 -d'>' | cut -f1 -d'<'  > ${theLinkNum}.info

setenv theLinkName `cat ${theLinkNum}.info`
echo ${theLinkName}
echo $1
echo $1 >> $theLinkNum.info

cat ${theLinkNum}.info | qrencode -c -o ${theLinkNum}.qrinfo.png 

echo "<a href=${1}>${theLinkName}<br><img src=${theLinkNum}.qrinfo.png><br>${1}</a>"
echo "<a href=${1}>${theLinkName}<br><img src=${theLinkNum}.qrinfo.png><br>${1}</a>" > $theLinkNum.html