Nslookup or dig in Google App Script -
is there way run nslookup / dig in google app script? m looking results of command in google spreadsheet.
thanks
find web service let use or post anonymously query dns info using restful api, , you'll able use urlfetchapp.fetch()
access it.
for example, statdns has simple api. here's custom function resolve domain name ipv4 address.
code
/** * peform network service lookup, using statdns api. * * @param {"google.com"} dn well-formed domain name resolve. * @return {string} resolved ip address * @customfunction */ function nslookup(dn) { var url = "http://api.statdns.com/%fqdn%/a".replace("%fqdn%",dn); var result = urlfetchapp.fetch(url,{mutehttpexceptions:true}); var rc = result.getresponsecode(); var response = json.parse(result.getcontenttext()); if (rc !== 200) { throw new error( response.message ); } var ip = response.answer[0].rdata; return ip; }
Comments
Post a Comment