#BEGIN 1.sh# rm *txt *sql wget http://tools.pipenetworks.com/lists/act.txt wget http://tools.pipenetworks.com/lists/nsw.txt wget http://tools.pipenetworks.com/lists/qld.txt wget http://tools.pipenetworks.com/lists/sa.txt wget http://tools.pipenetworks.com/lists/tas.txt wget http://tools.pipenetworks.com/lists/vic.txt ls *txt|while read i; do perl rangeconv.pl $i >> run.sql;done #END 1.sh, BEGIN rangeconv.pl# #!/usr/bin/perl -w # # pass text file with ranges as 1st param # rangeconv.pl act.txt # will output INSERT into ranges values ('203.206.192.0', '203.206.196.255', 'ACT') use Net::CIDR::Lite; $state = $ARGV[0]; open (CIDRLIST, "$state"); my $cidr = Net::CIDR::Lite->new; while () { ($c) = split(/,/); # Ranges don't start with a #, ignore those lines. if (!($c =~ m/^#/)) { $cidr->add($c); } } ($sqlstate) = split(/.txt/,$state); $sqlstate = uc $sqlstate; foreach $range ($cidr->list_range) { ($startip, $endip) = split(/-/, $range); print "INSERT into ranges values (\'$startip\', \'$endip\', \'$sqlstate\'); \n"; }