Scripting nslookup to resolve multiple hostnames


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Scripting nslookup to resolve multiple hostnames
# 1  
Old 06-30-2009
Scripting nslookup to resolve multiple hostnames

Hi Friends,

I have a list of servers with their production names in a file.
I want to know the best way eiter a command or a script that can do the following :-

Append "-bkp" to each hostnames at the end
And run nslookup and make sure I have valid backup IP add assigned to it.


Any help would be greatly appriciated. I did a for loop but nslookup is not running in iterative mode. Not sure what is the exact problem.

Thanks in advance.
# 2  
Old 06-30-2009
Code:
while read nodename
do
   nslookup ${nodename}-bkp | grep -q '^**' 
   if [[ $? -ne 0 ]] ; then
      echo "no backup for nodename ${nodename}"
   else
      echo " ${nodename} is good"
   fi   
done < listofnodes

This looks for the error string "*** No Address information" ...
If your nslookup error message is different change the grep statement.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Export Oracle multiple tables to multiple csv files using UNIX shell scripting

Hello All, just wanted to export multiple tables from oracle sql using unix shell script to csv file and the below code is exporting only the first table. Can you please suggest why? or any better idea? export FILE="/abc/autom/file/geo_JOB.csv" Export= `sqlplus -s dev01/password@dEV3... (16 Replies)
Discussion started by: Hope
16 Replies

2. Shell Programming and Scripting

Check for valid hostnames

Hello, I am trying to develop a script to check for valid hostnames. Below are the prerequisites for a valid hostname which I got from wiki : Hostnames are composed of series of labels concatenated with dots, as are all domain names. For example, "en.wikipedia.org" is a hostname. Each label... (8 Replies)
Discussion started by: rahul2662
8 Replies

3. Shell Programming and Scripting

Ip address for multiple hostnames

i have a file which has 100 servers,i want a script which can output me ip address and hostname for that server. Thanks in advance!! input file abc.com output file should be abc.com 192.168.1..1 (1 Reply)
Discussion started by: Moon1234
1 Replies

4. UNIX for Dummies Questions & Answers

Cyrillic Hostnames?

As the title suggests, I'm wondering if its possible to set a hostname to a name or word with Cyrillic letters (e.g. - Like the Russian alphabet). I tried installing the cyrillic-console package in Debian. I switched my desktop to Russian as well. However, when I try to set the hostname I get that... (2 Replies)
Discussion started by: Azrael
2 Replies

5. Programming

Getting All VM Hostnames Using Pysphere

I need to obtain a list of all the hostname of all the VM's that reside on two ESXI servers using pysphere. I have attempted using the basic methods but an unable to get a hostname in my testing using: from pysphere import VIServer server = VIServer() ... (0 Replies)
Discussion started by: metallica1973
0 Replies

6. HP-UX

nslookup/ping resolve problem 11i v3

I am having a problem with a new server build that has got me completely baffled. This server has a private back end network so the way it is supposed to work is that the server thinks its ip address is 10.131.0.48 but the rest of the world knows it as 199.68.100.100 per DNS. It has to be this way... (2 Replies)
Discussion started by: keelba
2 Replies

7. IP Networking

How to resolve hostnames on DHCP home network

Hi, I have a PC running Solaris 10 (hostname MARKUNIX) and a laptop running WinXP (hostname MARK-LAPTOP). Both are connected to broadband via a router. IP addresses for each are determined via DHCP (192.168.1.nn) and I do not leave either on, 24x7. I am running Oracle on MARKUNIX and... (1 Reply)
Discussion started by: ksdmnv
1 Replies

8. Shell Programming and Scripting

nslookup for reverse lookups on multiple servers

Hi all i need help :) i need to create a script (tcsh) to do a nslookup on all my hosts to see which ones do not have reverse lookup..etc. can someone please help? (1 Reply)
Discussion started by: brian112
1 Replies

9. IP Networking

DHCP and Hostnames

I have a linksys DSL router. I run a mixed environment of Windows, Linux and Solaris. The routers dhcp tables show the windows machines hostnames and associated IP's ok but the unix bases mahines don't have associated hostnames in the DHCP tables. I can ping by IP but not my the machines... (5 Replies)
Discussion started by: mr16ga
5 Replies

10. Solaris

I am too young not to be able to resolve myself...nslookup problem (no DNS available)

I don't have DNS, and would like to resolve EVERYTHING through local /etc/hosts file. My first sunbox has the following configuration: # hostname mybox.home.com My host file is as follows: # cat /etc/hosts # # Internet host table # 127.0.0.1 localhost 192.25.x.x ... (6 Replies)
Discussion started by: mr_manny
6 Replies
Login or Register to Ask a Question