My shell scripts #2 - WHOIS search

This time, we're going to get some informations about domains through WHOIS servers. All this via CLI interface and without the ubiquitous "whois" command (which is not available for my CPU architecture in OpenWrt package repository and I'm too lazy to cross-compile it myself). Used programs: "netcat", "sed", "grep".

The whois-servers.net server automatically redirects you to the WHOIS server responsible for the supplied TLD, so you don't have to remember them (and it also simplifies this script).
#!/bin/ash
if [ ! -n "$1" ]
then
  echo "Usage:"
  echo "  $0 domain.tld"
  exit 1
fi
tld=`echo $1 | sed 's/\/.*//' | grep -o '[[:alpha:]]*$'`
echo "$1" | netcat -T $tld.whois-servers.net 43
echo
exit 0

No comments:

Post a Comment