/ Published in: Bash
Helper to cheek if a given domain is available for registration. If tld is omitted the script uses a predefined tld array to check multiple domains.
To use copy the code to a standalone file, call it whatever you wants and make it executable (+x)
To use copy the code to a standalone file, call it whatever you wants and make it executable (+x)
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#!/usr/bin/env bash # ********************************************************* # file: dns # date: 18.10.2011 # author: (c) by Alex Sancho - <[email protected]> # description: Checks domain availability. # ********************************************************* function usage() { prname=$(basename $0) log "\t$prname: checks domain availability" log "\tUsage: $prname <domain>" log "\tExamp: $prname example.com" } function _main_() { if [[ "$1" == '-h' || "$1" == '--help' ]]; then usage exit 0 else local domain=${1} local tld=${domain##*.} if [[ "$tld" = "$domain" ]]; then DOMAINS=('.com' '.com.es' '.cat' '.net' '.info' '.mobi' '.org' '.tel' '.biz' '.tv' '.cc' '.eu' '.es') ELEMENTS=${#DOMAINS[@]} for (( i=0;i<$ELEMENTS;i++)); do dig soa $domain${DOMAINS[${i}]} | grep -q ^$domain${DOMAINS[${i}]} && echo "$domain${DOMAINS[${i}]} Registered" || echo "$domain${DOMAINS[${i}]} Available" done else dig soa $domain | grep -q ^$domain && echo "$domain Registered" || echo "$domain Available" fi fi } ## Run script... _main_ "$@"