creating script to perform a nslookup on all servers


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers creating script to perform a nslookup on all servers
# 1  
Old 06-23-2010
creating script to perform a nslookup on all servers

Hi All

i am trying to create a script (in tcsh) to do a nslookup on all the hosts i have here... can anyone help me?

Kind regards.

Brian
# 2  
Old 06-23-2010
Create a file that contains the names of all the host names (one host name per line) and then:
Code:
nslookup < file

# 3  
Old 06-23-2010
thank you for that... it was helpful. But i have a problem, what my goal is to retrieve all the hosts that have reverse PTR enabled. so i need to put all the hosts that have PTR enabled in one file, and then all the hosts that are not enabled into another file. so i can give this to our network guy to sort out. can you help?
# 4  
Old 06-23-2010
Hi, try if this works:
Code:
sh
nslookup < infile 2>/dev/null | awk '/Address/&&!/#/{print $2}' | nslookup -

Execute sh first, since this will not work from tcsh

or create a script with:
Code:
#!/bin/sh

on the first line

Last edited by Scrutinizer; 06-23-2010 at 08:25 AM..
# 5  
Old 06-23-2010
okay... sorry i am not following you with that one... how will i get all my hosts IP's into that? sorry... this has had me stumped for days now.
# 6  
Old 06-23-2010
The first nslookup and awk produce a list of all the ip addresses that belong to your hosts. This list then gets fed into the second nslookup that tries to perform a reverse lookup and see if it can find the host names. If it can't for a particular host, you know that PTR record is not defined..
# 7  
Old 06-23-2010
thank you very much... this helps tons! thank you
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Nslookup on a variable inside script not working

I am new at scripting. I have a file that each line is the shortname for a server. ie - Server1 Server2 Server3 I want to read in that file, do a nslookup and print the FQDN to a file. I added an echo statement to make sure my variable was being read and changing. But the nslookup... (5 Replies)
Discussion started by: kellyhkc
5 Replies

2. Shell Programming and Scripting

How to perform floating division in shell script?

I want to perform the below division operation in shell script and round the value. val1=6000 val2=5000 res=val1/val2 ----> 1.2---> Round to 2 Please help. (3 Replies)
Discussion started by: vel4ever
3 Replies

3. UNIX for Dummies Questions & Answers

How to perform string replace in shell script?

I have value like ABCDEF,BBCCDD in a shell variable, now i would like to have ABQWEF,BBQWDD in the same shell variable. How can i replace the char at position 3&4 with QW in shell script? (3 Replies)
Discussion started by: vel4ever
3 Replies

4. Shell Programming and Scripting

Script: nslookup few hosts at once

Hi Expert, Is there anyway for me to nslookup more than one host at one time, instead of doing it one by one. Thank you. (2 Replies)
Discussion started by: regmaster
2 Replies

5. Shell Programming and Scripting

shell script to take input from a text file and perform check on each servers and copy files

HI all, I want to script where all the server names will be in a text file like server1 server2 server3 . and the script should take servernames from a text file and perform copy of files if the files are not present on those servers.after which it should take next servername till the end of... (0 Replies)
Discussion started by: joseph.dmello
0 Replies

6. Shell Programming and Scripting

nslookup script but having syntax issues

Hi All i am creating a script to perform a nslookup on a specified host (so in otherwords it will be: zong(script name) 172.x.x.10(ip adress). i am scripting in tcsh. unfortunately i think i am doing something wrong as it keeps giving me syntax error. can someone help? @ num=1 set arg='ping... (2 Replies)
Discussion started by: brian112
2 Replies

7. 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

8. Shell Programming and Scripting

Trying to perform encryption through script

Hi, I have a small basic script encryption.sh as shown below. All I am trying to do is to encrypt a file which is passed through the script. It works fine when I execute this script directly from command line via putty or telnet but it does not work when I call this script in an... (3 Replies)
Discussion started by: simi28
3 Replies

9. Shell Programming and Scripting

help needed with creating challenging bash script with creating directories

Hi, Can someone help me with creating a bash shell script. I need to create a script that gets a positive number n as an argument. The script must create n directories in the current directory with names like map_1, map_2 etcetera. Each directory must be contained within its predecessor. So... (7 Replies)
Discussion started by: I-1
7 Replies

10. Shell Programming and Scripting

NSLOOKUP script

Hi Anyone know of a quick and simple way to script an NSLOOKUP's from a list/text file? Thanks, Gav (1 Reply)
Discussion started by: gavcollins
1 Replies
Login or Register to Ask a Question