home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / sendmail / uk-sendmail2.1 / Chncheck < prev    next >
Encoding:
Text File  |  1991-06-11  |  1.6 KB  |  73 lines

  1. #!/bin/sh
  2. #
  3. #    Chncheck - syntax check UK-Sendmail channel tables for obvious errors.
  4. #    Returns the number of errors found.
  5. #
  6. #    Copyright (c) 1988 Jem Taylor
  7. #
  8.  
  9.  
  10. if [ $# -lt 1 ]
  11. then    echo    usage: $0 files...
  12.     exit
  13. fi
  14. for i in $@
  15. do
  16.     sed -e 's/#.*//' -e '/^$/d' $i | awk '
  17. BEGIN    { bad=0; ok=1; format=ok }
  18. NF>2    { printf "%s: line %d - %d columns of data\n", file, NR, NF
  19.       format=bad
  20.     }
  21. /[][<>|\\(){}~`";:,?\/]/ {
  22.       printf "%s: line %d - bogus character\n", file, NR
  23.       format=bad
  24.     }
  25.     { for ( i=1 ; i <=2 ; i++ )
  26.       {    if (substr($i,1,1)==".")
  27.           {    printf "%s: line %d - leading dot column %d\n",\
  28.                     file, NR, i
  29.             format=bad
  30.         }
  31.         if ( substr($i,length($i),1) == "." )
  32.         {    printf "%s: line %d - trailing dot column %d\n",\
  33.                     file, NR, i
  34.             format=bad
  35.         }
  36.       }
  37.       if ( format == bad )
  38.       {    print "    " $0
  39.           format=ok
  40.           errval++
  41.       }
  42.     }
  43. END    { if ( errval > 0 )
  44.         printf "%d errors detected\n", errval
  45.       exit errval
  46.     } ' file=$i -
  47. done
  48.  
  49. #janet chan tends to blow this up because top domain is at front - adjust
  50. #the 'ignore' list to suit your janet.chn; if you have no janet chan then
  51. #delete the ignore list altogether. If you prefer, just exit here:
  52. #exit
  53.  
  54. # delete everything after the first whitespace
  55. duplicates=`sed -e '/^#/d' -e '/^$/d' -e 's/[     ].*//' $@ | sort | uniq -d`
  56.  
  57. exitcode=0
  58. if [ -n "$duplicates" ]
  59. then    for i in $duplicates
  60.     do    case $i in
  61.         uk|com|edu|us|ie|irl|nz|au|gov|uucp|arpa|dk|se|no|earn)
  62.             ;;
  63.         *)    echo "
  64. ---------    $i : duplicate or conflict    ---------"
  65.             egrep "^$i\$|^$i[     ]" $@ | sed -e 's/:/:    /'
  66.             echo
  67.             exitcode=99
  68.             ;;
  69.         esac
  70.     done
  71. fi
  72. exit $exitcode
  73.