Skip to content

Instantly share code, notes, and snippets.

@foxutech
Created October 8, 2018 12:04
Show Gist options
  • Save foxutech/53912112a703f0e4f505f00fd1abbe5c to your computer and use it in GitHub Desktop.
Save foxutech/53912112a703f0e4f505f00fd1abbe5c to your computer and use it in GitHub Desktop.
dns lookup script with loop.. https://foxutech.com
#!/bin/bash
hostname=foxu.tech
sleep_time=2
count=0
success_count=0
max_count=$((1*6))
while [ $count -lt $max_count ];
do
echo -n "$count/$max_count: "
date
nslookup $hostname
status=$?
if [ "$status" == "0" ]; then
success_count=$(($success_count + 1))
if [ $success_count -gt 1 ]; then
break
fi
fi
count=$(($count + 1))
echo "Sleeping $sleep_time"
sleep $sleep_time
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment