#!/bin/bash # tool to look up a swiss telephonenumber # usage: # "getnr 0001112233" prints to console # "getnr" brings up a GUI to input a number and displays a dialog # author: rakudave - rakudave@gmx.net if [ "$1" != "" ]; then # check for argument num=$1 else # if no argument, initialize GUI num=`zenity --entry --text="Telefonnummer:"` if [ "$num" = "" ]; then # exit on "cancel" event exit 0 fi fi `wget -q "http://tel.search.ch/result.html?was=$num"` # get html from query text=`iconv --from-code=ISO-8859-1 --to-code=UTF-8 result.html?was=$num | awk '/class="rname"/||/class="roccu"/||/class="raddr"/||/class="r_tel"/' | sed -e 's/<[^>]*>//g' | sed 's/Karte, SBB, vCard/\n\r/g' | sed 's/*//g'` # convert to UTF-8, parse html and remove crap if [ "$text" = "" ]; then # return error if no result found text="number unknown" fi if [ "$1" != "" ]; then # print to terminal if no GUI echo "$text" else # display info in messagebox `zenity --info --text="$text"` fi `rm result.html?was=$num*` # clean up exit 0