--- makeaslist.sh       2008-08-30 18:18:45.000000000 -0300
+++ makeaslist.sh       2010-08-11 11:12:04.655000486 -0300
@@ -0,0 +1,70 @@                                           
+#!/bin/sh                                                 
+#                                                         
+# makeaslist.sh - creates an ASN list from RIR's stats files
+# Copyright (C) 2010, Herbert Faleiros <herbert@faleiros.eti.br>
+#                                                               
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or   
+# (at your option) any later version.                                 
+#                                                                     
+# This program is distributed in the hope that it will be useful,     
+# but WITHOUT ANY WARRANTY; without even the implied warranty of      
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the       
+# GNU General Public License for more details.                        
+#                                                                     
+# You should have received a copy of the GNU General Public License   
+# along with this program; if not, write to the Free Software         
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+#                                                                          
+# Created at Tue Aug 10 19:44:08 BRT 2010                                  
+#                                                                          
+                                                                           
+                                                                           
+for RIR in afrinic apnic arin lacnic ripencc; do                           
+                                                                           
+  raw="${RIR}_`mcookie`.raw"                                               
+  tmp="${RIR}_`mcookie`.tmp"                                               
+  out="${RIR}_`mcookie`.out"                                               
+                                                                           
+  total=0                                                                  
+                                                                           
+  # downal                                                                 
+  wget ftp://ftp.`sed 's/ncc//' <<< ${RIR}`.net/pub/stats/${RIR}/delegated-${RIR}-latest -O ${raw}
+  cat ${raw} | grep asn | grep allocated | cut -d '|' -f 2,4,5 | tr '|' ' ' > ${tmp}              
+
+  while read line; do
+
+    country=`awk '{print $1}' <<< ${line}`
+        ASN=`awk '{print $2}' <<< ${line}`
+      block=`awk '{print $3}' <<< ${line}`
+
+      high=`cut -d. -f1 <<< ${ASN}`
+       low=`cut -d. -f2 <<< ${ASN}`
+
+      # asdot to asplain
+      echo ${ASN} | grep -q '\.' && ASN=`echo "${high} 65536*${low}+p" | dc`
+
+    if [ ${block} != 1 ]; then
+      for inc in `seq 0 ${block}`; do
+
+        ASN_inc=`expr ${ASN} + ${inc}`
+
+        printf '%6d\t'`echo ${RIR} | tr a-z A-Z`':'${country}'\n' ${ASN_inc} >> ${out}
+        echo ASN: ${ASN_inc}, country: ${country}
+
+        total=`expr ${total} + 1`
+      done
+    else
+      printf '%6d\t'`echo ${RIR} | tr a-z A-Z`':'${country}'\n' ${ASN} >> ${out}
+      echo ASN: ${ASN}, country: ${country}
+      total=`expr ${total} + 1`
+    fi
+  done < ${tmp}
+
+  echo -e "\n`echo ${RIR} | tr a-z A-Z` (total): ${total}\n"
+
+  cat ${out} | sort > as-${RIR}.txt
+  rm -f ${raw} ${tmp} ${out}
+done
+
