I want to read ip from IP Pool file and get whois from it and then report it to CSV spreadsheet file. I wrote this script to perform that:
#!/bin/bash
echo "ip,netname,org-name,remarks,descr,country,person,address,phone,origin" > csv
while read -r ip
do
whois $ip > whoisip
netname= cat whoisip | grep "netname"
orgname= cat whoisip | grep "org-name"
remarks= cat whoisip | grep "remarks"
descr= cat whoisip | grep "descr"
country= cat whoisip | grep "Country"
person= cat whoisip | grep "person"
address= cat whoisip | grep "address"
phone= cat whoisip | grep "phone"
origin= cat whoisip | grep "origin"
echo $ip,$netname,$orgname,$remarks,$descr,$country,$person,$address,$phone,$origin >> csv
done <pool
BUT, my script generate this CSV file:
ip,netname,org-name,remarks,descr,country,person,address,phone,origin
x.x.x.x,,,,,,,,
y.y.y.y,,,,,,,,
z.z.z.z,,,,,,,,
...
Why the second values are empty?