home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1999 March B
/
SCO_CASTOR4RRT.iso
/
base
/
root.15
/
etc
/
mail
/
vdomains
/
vdomains~
Wrap
Text File
|
1998-08-19
|
2KB
|
79 lines
#!/bin/osavtcl
#******************************************************************************
#
# Copyright (C) 1993-1997 The Santa Cruz Operation, Inc.
# All Rights Reserved.
#
# The information in this file is provided for the exclusive use of
# the licensees of The Santa Cruz Operation, Inc. Such users have the
# right to use, modify, and incorporate this code into other products
# for purposes authorized by the license agreement provided they include
# this notice and the associated copyright notice with any such product.
# The information in this file is provided "AS IS" without warranty.
#
#===============================================================================
set RESOLVER /usr/sbin/host
set IFCONFIG /usr/sbin/ifconfig
proc \
do_ifconfig {} \
{
global IFCONFIG
set ret [catch {exec $IFCONFIG -a} output]
if {$ret != 0} {
return ""
}
set lines [split $output "\n"]
# looking for two kinds of lines only, inet and (alias)
set inet ""
set alias ""
foreach line $lines {
if {"[csubstr $line 0 6]" == "\tinet "} {
set list [split $line " "]
set item [lindex $list 1]
lappend inet $item
}
if {"[csubstr $line 0 9]" == "\t(alias) "} {
set list [split $line " "]
set item [lindex $list 2]
lappend alias $item
}
}
# now remove from alias list everything that was found in inet
set newlist [lindex [intersect3 $inet $alias] 2]
return $newlist
}
proc \
do_resolve { list } \
{
global RESOLVER
set newlist ""
foreach item $list {
set ret [catch {exec $RESOLVER $item} output]
if {$ret != 0} {
continue
}
set lines [split $output "\n"]
# looking for Name field
foreach line $lines {
if {"[csubstr $line 0 6]" == "Name: "} {
set value [csubstr $line 6 end]
set value [string tolower $value]
set newitem [list $value $item]
lappend newlist $newitem
break
}
}
}
return $newlist
}
proc \
main {} \
{
set list [do_ifconfig]
set list [do_resolve $list]
foreach item $list {
echo $item
}
}
main