Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSLOOKUP in R (rstats)

Tags:

r

nslookup

I am new to scripting and R.

In the Windows cmd.exe I can perform an NSLOOKUP on a domain by:

nslookup www.google.com

I have a dataset of domain names that I would like to verify as valid or invalid as part of my grouping process in R. Is there a way to do NSLOOKUP in base R or one of the packages?

Edit1: I made some alterations to loop through 3 domains using the system call suggested. The call works, however the output will not save directly into a vector (line 7 below). How would I need to rework this line so that I can capture the output?

domains <- c('www.google.com','www.badtestdomainnotvalid.com','www.yahoo.com')
dns <- vector()
dnsreturn <-vector()
for(i in 1:length(domains)){
  dns[i] <- paste('nslookup ',domains[i],sep='')
  dnsreturn[i] <- system(dns[i],intern=TRUE)}
}
like image 979
Connie Marie Avatar asked Jan 25 '26 19:01

Connie Marie


1 Answers

If nothing else you could do

system("nslookup www.google.com", intern=TRUE)

In response to your edit:

domains = c('www.google.com','www.badtestdomainnotvalid.com','www.yahoo.com')
sapply(domains, function(x) system(paste("nslookup", x), intern=TRUE))

This will return a list of vectors, you can manipulate as you see fit beyond that

like image 57
geoffjentry Avatar answered Jan 28 '26 11:01

geoffjentry



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!