bash script for consulting via XML

well, here is a simple shell script I use to query callsigns’ information from You had to have the XML Logbook data plan from in order to use it.

Simply change the first two lines to use your username/password and voilá..


rm -f /tmp/login

xml2=`which xml2 2> /dev/null`
[ $? -ne 0 ] && { echo “missing xml2, please install it”; exit 1; };
wwget=`which wget 2> /dev/null
[ $? -ne 0 ] && { echo “missing wget, please install it”; exit 1; };

$wwget -q -O – “$username&password=$password”|egrep “<Key>”|awk -F”>” ‘{print $2}’|awk -F”<” {‘print $1’} > /tmp/login

$wwget -q -O – “`cat /tmp/login`;callsign=$1″|$xml2 > /tmp/lookup
fname=`cat /tmp/lookup|egrep “/fname” |cut -f2 -d ‘=’`
name=`cat /tmp/lookup|egrep “/name”|cut -f2 -d ‘=’`
addr1=`cat /tmp/lookup|egrep “/addr1″|cut -f2 -d ‘=’`
addr2=`cat /tmp/lookup|egrep “/addr2″|cut -f2 -d ‘=’`
zip=`cat /tmp/lookup|egrep “/zip”|cut -f2 -d ‘=’`
country=`cat /tmp/lookup|egrep “/country”|cut -f2 -d ‘=’`
state=`cat /tmp/lookup|egrep “/state”|cut -f2 -d ‘=’`

echo $fname $name
echo $addr1
[ -z “$addr2” ] || { echo $addr2; };
echo $state $zip
echo $country

I put the script under ~/bin/ (the bin under my home) and chmodded +x, then query for my own callsign here is the result:

[eperez@laptop ~]$ hc6pe
Ernesto (EPE) Perez Estevez
Las Toronjas 02-45 y Mandarinas
Ficoa, Ambato
TU EC180102

One thought on “bash script for consulting via XML”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.