Skip to content

Instantly share code, notes, and snippets.

@agirault
Last active May 3, 2018 19:23
Show Gist options
  • Save agirault/74a6a58b9bef4fb2801a84cba9cd20e5 to your computer and use it in GitHub Desktop.
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
#!/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