home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1999 March B / SCO_CASTOR4RRT.iso / base / root.15 / etc / mail / vdomains / vdomains~
Text File  |  1998-08-19  |  2KB  |  79 lines

  1. #!/bin/osavtcl
  2. #******************************************************************************
  3. #
  4. #    Copyright (C) 1993-1997 The Santa Cruz Operation, Inc.
  5. #        All Rights Reserved.
  6. #
  7. #    The information in this file is provided for the exclusive use of
  8. #    the licensees of The Santa Cruz Operation, Inc.  Such users have the
  9. #    right to use, modify, and incorporate this code into other products
  10. #    for purposes authorized by the license agreement provided they include
  11. #    this notice and the associated copyright notice with any such product.
  12. #    The information in this file is provided "AS IS" without warranty.
  13. #
  14. #===============================================================================
  15. set RESOLVER /usr/sbin/host
  16. set IFCONFIG /usr/sbin/ifconfig
  17. proc \
  18. do_ifconfig {} \
  19. {
  20.     global IFCONFIG
  21.     set ret [catch {exec $IFCONFIG -a} output]
  22.     if {$ret != 0} {
  23.         return ""
  24.     }
  25.     set lines [split $output "\n"]
  26.     # looking for two kinds of lines only, inet and (alias)
  27.     set inet ""
  28.     set alias ""
  29.     foreach line $lines {
  30.         if {"[csubstr $line 0 6]" == "\tinet "} {
  31.             set list [split $line " "]
  32.             set item [lindex $list 1]
  33.             lappend inet $item
  34.         }
  35.         if {"[csubstr $line 0 9]" == "\t(alias) "} {
  36.             set list [split $line " "]
  37.             set item [lindex $list 2]
  38.             lappend alias $item
  39.         }
  40.     }
  41.     # now remove from alias list everything that was found in inet
  42.     set newlist [lindex [intersect3 $inet $alias] 2]
  43.     return $newlist
  44. }
  45. proc \
  46. do_resolve { list } \
  47. {
  48.     global RESOLVER
  49.     set newlist ""
  50.     foreach item $list {
  51.         set ret [catch {exec $RESOLVER $item} output]
  52.         if {$ret != 0} {
  53.             continue
  54.         }
  55.         set lines [split $output "\n"]
  56.         # looking for Name field
  57.         foreach line $lines {
  58.             if {"[csubstr $line 0 6]" == "Name: "} {
  59.                 set value [csubstr $line 6 end]
  60.                 set value [string tolower $value]
  61.                 set newitem [list $value $item]
  62.                 lappend newlist $newitem
  63.                 break
  64.             }
  65.         }
  66.     }
  67.     return $newlist
  68. }
  69. proc \
  70. main {} \
  71. {
  72.     set list [do_ifconfig]
  73.     set list [do_resolve $list]
  74.     foreach item $list {
  75.         echo $item
  76.     }
  77. }
  78. main
  79.