- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- nslookup shell script with input and output files
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-07-2007 08:11 AM
тАО03-07-2007 08:11 AM
I have a slight dilema, the data in my forward and reverse zones differ quite a bit. How would I write a shell script that would take an input file list of fqdn or ip and run nslookup on them and output a log file based on the results? I wrote one a while ago for batch but I am just learning unix/shell.
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=960329
Is very close to what I need. Thanks in advance!
Solved! Go to Solution.
- Tags:
- nslookup
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-07-2007 08:20 AM
тАО03-07-2007 08:20 AM
Re: nslookup shell script with input and output files
This could be as simple as:
# cat .mylookup.sh
while read ADDR
do
nslookup ${ADDR} | tee -a mylookup.log
done < mylookup
...where 'mylookup' is a file with one IP or FQDN per line:
10.10.11.12
host01.xyz.net
host02.xyz.net
...run as:
# ./mylookup.sh
...Your output will be written to your terminal and to the 'mylookup.log' file.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-07-2007 09:52 AM
тАО03-07-2007 09:52 AM
Re: nslookup shell script with input and output files
and if it doesn't
Thanks so far, your help is very much appreciated!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-07-2007 11:00 AM
тАО03-07-2007 11:00 AM
SolutionOK, here's a simple hack:
# cat ./mylookup
#!/usr/bin/sh
while read ADDR
do
RESULT=`nslookup ${ADDR} | grep -E "^Address:"`
if [ ! -z "${RESULT}" ]; then
echo "${ADDR} is_ok" | tee -a mylookup.log
fi
done < mylookup
...run this just as you did the first version. Good results have a line in their output that begins with "Address:". The caret (^) anchors the pattern to match to the beginning of the line. Thus only lines that start with "Address:" are captured. If nothing matches, then 'nslookup' reports the target in the error returned, so we just print that.
Have a look at the manpages for 'nslookup'.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-07-2007 11:08 AM
тАО03-07-2007 11:08 AM