Skip to content

Instantly share code, notes, and snippets.

@guelau
Last active August 29, 2015 14:09
Show Gist options
  • Save guelau/737817b9f3d63819e91a to your computer and use it in GitHub Desktop.
Save guelau/737817b9f3d63819e91a to your computer and use it in GitHub Desktop.
Check the domaine name status and send an email when "domain-name" is entered redemption period
#!/bin/bash
DOMAIN_NAME=$1
MAIL=$2
if [ "x$2" = "x" ]; then
echo "Usage: $0 domain-name.ltd email-adress";
echo "Example: $0 example.com [email protected]"
exit;
fi
echo "Redemption Period check for $DOMAIN_NAME";
WHOIS=$(whois $DOMAIN_NAME)
RESULT=$(echo $WHOIS | grep -i "Status: pendingDelete" | wc -l)
if [ $RESULT != "0" ]; then
echo -e "Redemption Period is over for $DOMAIN_NAME\n\n\n$WHOIS" | mail -s "[$DOMAIN_NAME] Redemption Period" $MAIL
echo "A E-Mail message will be sent to $MAIL"
echo "Redemption period is over for $DOMAIN_NAME, ending process.";
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment