Operating System - HP-UX
1753912 Members
8798 Online
108810 Solutions
New Discussion юеВ

Re: 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 3
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...