Last active
May 3, 2018 19:23
-
-
Save agirault/74a6a58b9bef4fb2801a84cba9cd20e5 to your computer and use it in GitHub Desktop.
run as `./nslookupAlert.sh ${domain}` on macos to receive an alert when a domain DNS is resolved
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
domain=$1 | |
echo -ne "Looking up $domain DNS: " | |
while true; do | |
nslookup $domain | grep -q "find" | |
retVal=$? | |
if [ $retVal -ne 0 ]; then | |
ip=$( nslookup $domain | awk -F': ' 'NR==6 { print $2 } ') | |
echo "$domain found at $ip" | |
osascript -e "tell app \"System Events\" to display dialog \"$domain found at $ip\"" >/dev/null | |
break | |
else | |
echo -ne "." | |
fi | |
sleep 5 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment