#! /bin/sh -
#
# 5799-WZQ (C) COPYRIGHT IBM CORPORATION 1988
# LICENSED MATERIALS - PROPERTY OF IBM
# REFER TO COPYRIGHT INSTRUCTIONS FORM NUMBER G120-2083
#
# $Header:host_name 12.0$ 
# $ACIS:host_name 12.0$ 
# $Source: /ibm/acis/usr/sys/dist/RCS/host_name,v $ 
#
#	This shell script takes a host name or address as an
#	argument and returns the corresponding host name
#	which must be listed in /etc/hosts.  It does little
#	error checking and is intended only for use by the
#	miniroot diskette.
#

OLDHOSTNAME=${1}

NEWHOSTNAME=`awk 'BEGIN \
                  {
                    hostname="'${OLDHOSTNAME}'"
                    printed=0
                  }
                  ($0~/^#/) \
                  {
                    next
                  }
                  {
                    for (i=1; i<=NF; i++)
                    {
                      if ($i == hostname)
                      {
                        print $2
                        printed++
                        exit 0
                      }
                    }
                  }
                  END \
                  {
                    if (!printed)
                    {
                      print hostname
                    }
                  }' /etc/hosts`
echo ${NEWHOSTNAME}
