Skip to content

Instantly share code, notes, and snippets.

@theasder
Created December 8, 2018 12:57
Show Gist options
  • Save theasder/e0ab686d7e1e9644df056029476b1314 to your computer and use it in GitHub Desktop.
Save theasder/e0ab686d7e1e9644df056029476b1314 to your computer and use it in GitHub Desktop.
#!/bin/bash
get_whois() { # directory, url as arguments
if [[ "$2" =~ ^https?:\/\/.*$ ]];
then
domain=$(echo $2 | awk -F[/:] '{print $4}')
else
domain=$2
fi
domain=${domain/www./ }
filename=${domain//./_}
wget --output-document="$1/${filename}.html" "https://www.whois.com/whois/${domain}"
}
if [ ! $# == 3 ]; then
echo "Incorrect input"
exit
if [ "$2" == "domain" ];
then
get_whois "$1" "$3"
elif [ "$2" == "file" ];
then
cat "$3" | while read line
do
get_whois "$1" "$line"
done
else
echo "Incorrect input"
exit
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment