Hello,
I wrote a basic script to query a whois server using the whois system command to retrieve information about IP's. I have file containing the ip addresses which I feed to the whois command via a while loop. This seems to work sometimes. Most of the time, the whois command seems not to return any data back - it skips many ip's. It is almost if the script runs too quickly for the whois command to return results or to write to the output file??? However I do know that all ip addresses should return data back, since when I run the whois command manually, data is returned on every ip, even the ones that don't return in the script.
I put a sleep command in, but it doesn't help...
So, in other words:
******************************************************************************
[Querying whois.completewhois.com]
[whois.completewhois.com]
******************************************************************************
means that the whois results did not write to the output file.
Here is my script:
-----------------------------------------------------------------
#!/bin/bash
while read ip_address
do
whois -h [some hostname here...] $ip_address >> whois_results
sleep 20
## line separator
echo "***************" >> whois_results
done < unique_ip.list
-----------------------------------------------------------------
And here is whois_results:
-----------------------------------------------------------------
[Querying whois.completewhois.com]
[whois.completewhois.com]
Completewhois.Com Whois Server, Version 0.91a33, compiled on May 28,
2006
Please see
http://www.completewhois.com/help.htm for command-line
options
Use of this server and any information obtained here is allowed only
if you follow our policies at
http://www.completewhois.com/policies.htm
[IPv4 whois information for 128.194.135.94 ]
[whois.arin.net]
OrgName: Texas A&M University
OrgID: TAMU
Address: Network Services
Address: Computing & Information Services
Address: Mail Stop 3142
City: College Station
StateProv: TX
PostalCode: 77843-3142
Country: US
NetRange: 128.194.0.0 - 128.194.255.255
CIDR: 128.194.0.0/16
NetName: TAMU-NET
NetHandle: NET-128-194-0-0-1
Parent: NET-128-0-0-0-0
NetType: Direct Allocation
NameServer: NS1.TAMU.EDU
NameServer: NS2.TAMU.EDU
NameServer: NS3.TAMU.EDU
NameServer: DNS1.LATECH.EDU
Comment:
RegDate: 1987-01-16
Updated: 2005-09-22
RTechHandle: NG16-ORG-ARIN
RTechName: Network Services
RTechPhone: +1-979-862-2222
RTechEmail:
tech@net.tamu.edu
OrgTechHandle: NG16-ORG-ARIN
OrgTechName: Network Services
OrgTechPhone: +1-979-862-2222
OrgTechEmail:
tech@net.tamu.edu
# ARIN WHOIS database, last updated 2007-06-22 19:10
# Enter ? for additional hints on searching ARIN's WHOIS database.
******************************************************************************
[Querying whois.completewhois.com]
[whois.completewhois.com]
******************************************************************************
[Querying whois.completewhois.com]
[whois.completewhois.com]
******************************************************************************
[Querying whois.completewhois.com]
[whois.completewhois.com]
******************************************************************************
[Querying whois.completewhois.com]
[whois.completewhois.com]
******************************************************************************
[Querying whois.completewhois.com]
[whois.completewhois.com]
******************************************************************************
[Querying whois.completewhois.com]
[whois.completewhois.com]
******************************************************************************
[Querying whois.completewhois.com]
[whois.completewhois.com]
Completewhois.Com Whois Server, Version 0.91a33, compiled on May 28,
2006
Please see
http://www.completewhois.com/help.htm for command-line
options
Use of this server and any information obtained here is allowed only
if you follow our policies at
http://www.completewhois.com/policies.htm
[IPv4 whois information for 64.246.165.50 ]
[whois.arin.net]
OrgName: Compass Communications, Inc.
OrgID: CPCM
Address: 2001 6th Avenue
Address: Suite 3205
City: Seattle
StateProv: WA
PostalCode: 98121
Country: US
ReferralServer: rwhois://rwhoisd.ccom.net:4321
NetRange: 64.246.160.0 - 64.246.191.255
CIDR: 64.246.160.0/19
NetName: CCOM-2003
NetHandle: NET-64-246-160-0-1
Parent: NET-64-0-0-0-0
NetType: Direct Allocation
NameServer: NS1.CCOM.NET
NameServer: NS2.CCOM.NET
Comment:
RegDate: 2003-05-16
Updated: 2004-03-10
OrgTechHandle: IC122-ARIN
OrgTechName: COMPASS COMMUNICATIONS, INC.
OrgTechPhone: +1-206-777-9988
OrgTechEmail:
hostmaster@ccom.net
# ARIN WHOIS database, last updated 2007-06-22 19:10
# Enter ? for additional hints on searching ARIN's WHOIS database.
[RWHOIS: RWHOISD.CCOM.NET]
error querying rwhois server: Could not connect to host
******************************************************************************
[Querying whois.completewhois.com]
[whois.completewhois.com]
******************************************************************************
[Querying whois.completewhois.com]
[whois.completewhois.com]
******************************************************************************
[Querying whois.completewhois.com]
[whois.completewhois.com]
******************************************************************************
[Querying whois.completewhois.com]
[whois.completewhois.com]
******************************************************************************
Thank you,
Alex