Check DNS changed
This script waits until the given IP address is successfully associated with a domain name. Therefore it pings the domain and checks if the returned IP address matches the input IP address. For each request, the DNS cache is flushed before.
# Wait until the given IP address is associated with a domain
require "dialog";
require "strings";
const QUERY_DELAY int <= 10000;
global szTargetDomain string;
global szNewIPAddr string;
global bQueryResult bool;
function check_dns_change bool(domain string, addr string)
{
result false;
local output string;
local find int;
sys { ipconfig /flushdns } output;
sys { ping %domain -n 1} output;
s_find "%output" "%addr" find;
if (%find, -gr, 0) {
result true;
};
};
input szTargetDomain "Please enter the domain to check: ";
input szNewIPAddr "Please enter the new IP address of the domain: ";
print "Waiting for address change...";
while (%bQueryResult, -nt, true) {
call check_dns_change("%szTargetDomain", "%szNewIPAddr") => bQueryResult;
if (%bQueryResult, -eq, true) {
print "Change applied, job done.";
} else {
sleep %QUERY_DELAY;
};
};