home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / NETWORK / ISP / bind.4.8.3.lzh / BIND483 / EXAMPLES / ch07.get_cache.sh < prev    next >
Linux/UNIX/POSIX Shell Script  |  1994-01-09  |  623b  |  39 lines

  1. #!/bin/sh
  2.  
  3. ROOT=terp.umd.edu.
  4. TMPFILE=/tmp/ns.$$
  5. CACHETMP=/tmp/db.cache.tmp
  6.  
  7. #
  8. # Look up root server information and store it in a temporary file.
  9. #
  10. nslookup >$TMPFILE <<-EOF
  11. server $ROOT
  12. set type=ns
  13. .
  14. EOF
  15.  
  16. #
  17. # Generate the the db.cache file from the nslookup output.  Store
  18. # it in a temporary file.
  19. #
  20. cat $TMPFILE | awk '
  21.   /(root)/ {printf "%-20s 99999999 IN  NS %s.\n", ".", $NF}
  22.   /address/ {printf "%-20s 99999999 IN  A  %s\n", $1 ".", $NF}
  23.   ' > $CACHETMP
  24.  
  25. #
  26. # Move the new db.cache in place if it is not empty.
  27. #
  28. if test -s $CACHETMP
  29. then
  30.   mv $CACHETMP db.cache
  31. else
  32.   rm $CACHETMP
  33. fi
  34.  
  35. #
  36. # Clean up.
  37. #
  38. rm $TMPFILE
  39.