SUMMARY: Script on Solaris 8

From: rmckee <rmckeever_at_earthlink.net>
Date: Thu Nov 21 2002 - 15:15:32 EST
Thanks everybody for there input here is what I came up with:

# more name2add.sh
#!/bin/bash
#
# Argument 1 is the input file 
# Argument 2 is the output file
# Script will run whois on IP's that failed nslookup, and create a log of
those IP's with output of whois
#
WHOFILE=who.out
WHOISFILE=whois.out
 
 
# Run nslookup on IP's.
 
for x in `cat $1`
do
SEARCH=`/usr/local/bin/nslookup -sil $x | grep name |awk '{print $2, $3, $4}'`

if [ -z "$SEARCH" ]; then 
echo $x >> $WHOFILE
else
echo "IP is $x:" >>$2 
echo $SEARCH >> $2 
echo " " >>$2 
fi
done
 
# Will exit if all IP's are able to be looked up. If not will
# run Whois on IP's that failed nslookup.
 
if [ -f "$WHOFILE" ]; then
COUNT=`wc -l $WHOFILE| awk '{print $1}'`
echo "$COUNT IP's that failed nslookup..."
echo "Running Whois on those IP's...."
for y in `cat $WHOFILE`
do
echo "######### IP is $y: " >> $WHOISFILE
/bin/whois -h whois.arin.net $y >> $WHOISFILE
echo " " >> $WHOISFILE
done
rm $WHOFILE > /dev/null 2>&1
echo "The file $WHOISFILE will contain output from whois...."
 fi
exit 0
# 

================
Example Running:

# ./name2add.sh addr.list output
22 IP's that failed nslookup...
Running Whois on those IP's....
The file whois.out will contain output from whois....
#
#
# ls -l output whois.out
-rw-------   1 root     other       3559 Nov 21 09:38 output
-rw-------   1 root     other      15452 Nov 21 09:39 whois.out
#

# head output
IP is 12.251.129.189:
name = 12-251-129-189.client.attbi.com. nameserver = ns1.attbi.com. nameserver
= ns2.attbi.com.
 
IP is 12.253.172.106:
name = 12-253-172-106.client.attbi.com. nameserver = ns2.attbi.com. nameserver
= ns1.attbi.com.
 
IP is 12.64.25.164:
name = slip-12-64-25-164.mis.prserv.net. nameserver =
ohcu.oh.mt.np.els-gms.att.net. nameserver = macu.ma.mt.np.els-gms.att.net.
nameserver = wycu.wy.br.np.els-gms.att.net. nameserver =
orcu.or.br.np.els-gms.att.net.

# head whois.out
######### IP is 10.0.2.1: 
 
OrgName:    Internet Assigned Numbers Authority 
OrgID:      IANA
 
NetRange:   10.0.0.0 - 10.255.255.255 
CIDR:       10.0.0.0/8 
NetName:    RESERVED-10
NetHandle:  NET-10-0-0-0-1
Parent:     
# 


Thanks
RM
_______________________________________________
sunmanagers mailing list
sunmanagers@sunmanagers.org
http://www.sunmanagers.org/mailman/listinfo/sunmanagers
Received on Thu Nov 21 15:19:29 2002

This archive was generated by hypermail 2.1.8 : Thu Mar 03 2016 - 06:42:58 EST