HPE Community read-only access December 15, 2018
This is a maintenance upgrade. You will be able to read articles and posts, but not post or reply.
Hours:
Dec 15, 4:00 am to 10:00 am UTC
Dec 14, 10:00 pm CST to Dec 15, 4:00 am CST
Dec 14, 8:00 pm PST to Dec 15, 2:00 am PST
System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

nslookup or dig on instance names from a file

 
SOLVED
Go to solution
Shivkumar
Super Advisor

nslookup or dig on instance names from a file

Hi,

I have some instance names like aa-neptune-bb1-xx to aa-neptune-bb25-xx.
I want to perform nslookup at one time for all the instances which is stored in a file.

This is to verify whether all the instance names can resolve successfully to some IPs.

Is there any way how to do it ?

Thanks,
Shiv
3 REPLIES
James R. Ferguson
Acclaimed Contributor
Solution

Re: nslookup or dig on instance names from a file

HI Shiv:

One way is:


#!/usr/bin/sh
while read HOST
do
RSLT=$( 2>&1 nslookup ${HOST} > /dev/null )
[ -z "${RSLT}" ] && echo "'${HOST}' OK" || echo "'${HOST}' NOT OK"
done < myhostnames
exit 0

This uses a file called 'myhostnames' with on hostname or FQDN per line as input.

Regards!

...JRF...
Shivkumar
Super Advisor

Re: nslookup or dig on instance names from a file

James,

This script works fine. Thanks for your help!!

One more question:
How do i redirect output in a file so that it can be viewed later on ?

Regards,
Shiv
James R. Ferguson
Acclaimed Contributor

Re: nslookup or dig on instance names from a file

Hi (again) SHiv:

> One more question: How do i redirect output in a file so that it can be viewed later on ?

You could do:

# #!/usr/bin/sh
typeset LOG=/var/tmp/nslookup.log
while read HOST
do
RSLT=$( 2>&1 nslookup ${HOST} > /dev/null )
[ -z "${RSLT}" ] && echo "'${HOST}' OK" >> ${LOG}|| echo "'${HOST}' NOT OK" >> ${LOG}
done < myhostnames
exit 0

Regards!

...JRF...