Files
Justin Oros 276a6223a3 Upload bash script crex.sh
Query domain name creation and expiration dates.
2023-09-29 11:09:12 -07:00

51 lines
1009 B
Bash

#!/bin/bash
# Description: Query Domain Name Creation and Expiration dates.
# Usage: crex.sh <domain.tld>
# Author: Justin Oros
# Source: https://github.com/JustinOros
# Dependency Checks
TARGET_FILE='/usr/bin/whois'
if [ ! -f "$TARGET_FILE" ]
then
echo "$TARGET_FILE does not exist."
exit
fi
TARGET_FILE='/usr/bin/grep'
if [ ! -f "$TARGET_FILE" ]
then
echo "$TARGET_FILE does not exist."
exit
fi
TARGET_FILE='/usr/bin/awk'
if [ ! -f "$TARGET_FILE" ]
then
echo "$TARGET_FILE does not exist."
exit
fi
TARGET_FILE='/usr/bin/head'
if [ ! -f "$TARGET_FILE" ]
then
echo "$TARGET_FILE does not exist."
exit
fi
# User Input
DOMAIN_NAME=$1
# Get Creation Date
CREATION_DATE=$(whois $DOMAIN_NAME | grep 'Creation' | awk '{print $3;}' | head -n 1)
# Get Expiration Date
EXPIRATION_DATE=$(whois $DOMAIN_NAME | grep 'Expiration' | awk '{print $5;}')
# Output Results
echo '-'
echo 'Domain:' $DOMAIN_NAME
echo 'Creation:' $CREATION_DATE
echo 'Expiration:' $EXPIRATION_DATE
echo '-'