bash/unix shell scripting - parse IPs, AS lookup

Closed - This job posting has been filled and work has been completed.
IT & Networking Other - IT & Networking Posted 1 year ago

Fixed Price

Delivery by April 7, 2014

$5.00

Budget

Details

Return

1) a bash script that performs as follows; and
2) a .txt file of results

For a .txt input file of IPs in this format:

to 100.4.25.148
93.95.227.2 [AS44925]
178.19.50.168 [AS44735]
* 24.222.79.114
24.222.79.113 [AS11260]
24.215.101.77 [AS11260]
24.215.101.221 [AS11260]
24.215.102.10 [AS11260]
77.67.70.77 [AS3257]
89.149.181.110 [AS3257]
152.179.72.121 [*]
130.81.199.219 [*]
130.81.194.161 [*]

I want a script to return the missing ASes and insert them into a new, complete output file that includes all info from the input file PLUS the missing AS lookups.
For example, the AS for 152.179.72.121 to replace the *
The answer is AS701
use geoiplookup
      Debian: apt-get install geoip-bin geoip-database-contrib

Suggested workflow:
1. load each line in existing traceroute-data.txt-hostname file
2. if exist [AS], then
      geoiplookup  [ipaddress]
      parse country code, country, city, lat/long, skip {AS]
      write the line including AS to a new file
4. else if missing AS, then
      geoiplookup [ipaddress]
      parse AS, country code, country, city, lat/long
      write IP and new data to the new file
5 loop

Output file should look like:
to 100.4.25.148
93.95.227.2 [AS44925 ASname] DE  Germany   Berlin  40.1" 39.2'
178.19.50.168 [AS44735 ASname] US  United States  Boston  40.1" 39.2'
24.222.79.114 [ASxxx ASname] DE  Germany   Berlin  40.1" 39.2'
24.222.79.113 [AS11260 ASname] DE  Germany   Berlin  40.1" 39.2'
24.215.101.77 [AS11260 ASname] DE  Germany   Berlin  40.1" 39.2'
24.215.101.221 [AS11260 ASname] US  United States  Boston  40.1" 39.2'
24.215.102.10 [AS11260 ASname] US  United States  Boston  40.1" 39.2'
77.67.70.77 [AS3257 ASname] US  United States  Boston  38 97
89.149.181.110 [AS3257 ASname] US  United States  Boston  40.1" 39.2'
152.179.72.121 [AS701 MCI Communications Services, Inc. d/b/a Verizon Business] US  United States  Boston  40.1" 39.2'
130.81.199.219 [AS701 MCI Communications Services, Inc. d/b/a Verizon Business] US  United States  Boston  38 97
130.81.194.161 [AS701 MCI Communications Services, Inc. d/b/a Verizon Business] US  United States  Boston  38 97

The record return format i seek for each row is, for example:

130.81.194.161 [AS701 MCI Communications Services, Inc. d/b/a Verizon Business] US  United States  Boston  38 97

which is:

IP                      130.81.194.161
AS number       AS701
AS name           MCI Communications Services, Inc. d/b/a Verizon Business
country code     US
country              United States
Lat                     38
Long                  97

if you try geoiplookup 178.19.50.168

you get:
GeoIP Country Edition: IS, Iceland
GeoIP City Edition, Rev 1: IS, 10, Gullbringusysla, Reykjavík, N/A, 64.150002, -21.950001, 0, 0
GeoIP ASNum Edition: AS44735 Simafelagid ehf

so you return,
178.19.50.168  AS44735 Simafelagid ehf
IS, Iceland
10, Gullbringusysla, Reykjavík, N/A, 64.150002, -21.95000


About the Client

(4.89) 7 reviews

United States
Cambridge 12:25 AM

15 Jobs Posted
60% Hire Rate, 1 Open Job

$208 Total Spent
13 Hires, 0 Active

$16.67/hr Avg Hourly Rate Paid
5 Hours

Member Since Jul 18, 2013