I have a shell script that currently pulls data from a mysql database and writes it to a .csv file. The problem is I would like to do a whois lookup against each public IP to see where they are coming from. I basically have two firewalls writing syslog data to a mysql database and want to make sense of the data.

.csv data output

"ReceivedAt","External","Hit_Count","Port"
"2010-04-21 00:04:43","189.24.154.198","1120","445"
"2010-04-21 00:17:16","221.195.73.86","14","1080"
"2010-04-21 00:17:07","221.195.73.86","12","8000"
"2010-04-21 05:12:12"," 119.39.248.178","10","22"
"2010-04-21 05:12:12","119.39.248.178","10","22"
"2010-04-21 09:26:51","222.37.37.33","8","1434"

Thanks in Advance,
-lo

Hello,

try this where one.csv is your file and it will create a file with the IP address as the name with the whois data,

for x in `cat one.csv  | sed s/\"//g | awk -F, {' print $2 '} `; do  whois $x > $x; done
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.