#! /bin/sh
################################################################################
# PROJECT:
#   LANE MACHINE USER INTERFACE
#
# FILE NAME:
#  get_ip_address
#
# PURPOSE:
#  This script returns the current ip address of the specified device.
#
# NOTES:
#  Input value is the device to check. example: eth0 or eth1
#  The default value is eth0
#
# COPYRIGHT NOTICE:
#  Copyright 2004 All rights reserved
#  Brunswick Corp.
#  Proprietary Information
#
# REVISION HISTORY:
#     $Id: get_ip_address,v 1.1 2004/11/12 19:42:27 mmead Exp $
################################################################################
IFCONFIG="/sbin/ifconfig"
DEVICE="eth0"
GREP="/bin/grep"
SED="/bin/sed"

# Test input
if [ $# != 0 ]
    then
    DEVICE="$1"
fi

# Get ip address
$IFCONFIG $DEVICE | $GREP 'inet addr' | $SED -e \
  s/'^[ ]\{1,10\}inet addr:\([0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\)[^ ]*  .*$'/'\1'/g

exit 0
