home *** CD-ROM | disk | FTP | other *** search
/ Education Sampler 1992 [NeXTSTEP] / Education_1992_Sampler.iso / Programming / Source / WAIS / bin / getaddrs < prev    next >
Encoding:
Text File  |  1992-02-02  |  924 b   |  34 lines

  1. #!/bin/sh
  2. # this is a simple script for converting the addresses in a server log
  3. # to internet domain names.
  4.  
  5. # the argument to this script is the name of the server log file.
  6.  
  7. if (test $# -eq 0)
  8. then
  9.     echo "usage: $0 <server-log-file>"
  10.     echo "  converts IP addresses in <server-log-file> to IP names."
  11.     exit 1
  12. fi
  13.  
  14. addrs=/tmp/addrs.$$
  15.  
  16. grep -i from: $* | \
  17.  awk '{if ($10 == "from:") {print $11} else {print $10}}' | \
  18.  sort | \
  19.  awk '$1 != last { print $1; last = $1 }' | \
  20.  awk -F. '{print $4"."$3"."$2"."$1".in-addr.arpa"}' >> $addrs
  21.  
  22. scriptfile=/tmp/script.$$
  23. echo "set q=ptr" > $scriptfile
  24. cat $addrs >> $scriptfile
  25.  
  26. /usr/etc/nslookup < $scriptfile | grep "host name" | \
  27.  awk -F. '{ {printf "%s.%s.%s.%s %s",$4,$3,$2,$1,$6} { for (i = 7; i <= NF;
  28. i++) { printf ".%s",$i } } {printf "\n"} }' | \
  29.  awk '{printf ("%-16s %s\n", $1,$6)}' | sort -n
  30.  
  31. wc -l $addrs | awk '{print $1 " different hosts"}'
  32.  
  33. rm $scriptfile $addrs
  34.