home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / smail-3.1.28 / samples / queryprog / query.sh < prev    next >
Encoding:
Linux/UNIX/POSIX Shell Script  |  1990-10-23  |  967 b   |  34 lines

  1. #!/bin/sh
  2. # @(#)samples/queryprog/query.sh    1.2 10/24/90 05:21:26
  3. #
  4. # match hosts in a shell case statement.  It is generally more
  5. # efficient to use a paths file and a method file to perform this kind
  6. # of routing.
  7. #
  8. # See the source file samples/queryprog/routers for more information
  9. # on how this shell script is to be used as part of a complete router
  10. # file entry.
  11.  
  12. # The hostname is passed as the first argument, write a path and
  13. # transport for each host that we match.  Alternately, no transport is
  14. # output if the default is sufficient.
  15. case "$1" in
  16.  
  17. \[*)    # look for internet addresses in square brackets
  18.     inet=`echo "$1" | sed -n 's/^\[\([0-9.]*\)\]$/[\1]/p'`
  19.     if [ "$inet" ]; then
  20.         echo $inet smtp
  21.     else
  22.         exit 1
  23.     fi;;
  24. foo)    echo foo uusmtp;;
  25. bar)    echo foo!bar uusmtp;;
  26. curds)    echo curds;;
  27. whey)    echo curds!whey;;
  28. *' '*|*'    '*) exit 1;;    # watch out for hostnames with whitespace
  29. *)    echo foo!$1 uusmtp;;    # forward mail for unknown hosts to foo
  30.  
  31. esac
  32.  
  33. exit 0
  34.