Google
 

Tuesday, June 14, 2011

NTC PSTN Number to Name

NTC's website has a nice feature called Telephone search. This is particularly handy when you get a call from landline (PSTN) number and have no idea who's calling. Ofcourse you can go to the site and search, but the following bash script makes it faster.

#!/bin/bash

#
# Nepal Telecom PSTN Number to Name search
#

if [ "$1" == "" ] ; then
echo "Usage: " $0 "phone_number"
exit
fi

# Prefix 01, if not provided
if [[ $1 =~ ^01 ]] ; then
NUMBER=$1
else
NUMBER="01$1"
fi

wget -q http://ntc.net.np/telsearchRes.php
--post-data "searchFor=name&telno=$NUMBER&submitted=Search" -O - | html2text | grep "$NUMBER" | tr '_' ' ' | sed 's/ [\ ]*/ /g'

Save the file, chmod it as executable.

To use,
./telsearch 5544132
| 1 |015544132|Ntc |Cellular Mobile And New S|Jawalakhel|