Leslie,
Here you go. I have done limited testing and this seems to work just fine.
#!/usr/bin/ksh
# File : getNetwork
# Shell script to calculate the Network Address given an
# IP Address on the network and the Subnet Mask
# Created by : Don Davis 19APR01
# Note that "&" is the korn shell bitwise AND operator
# Syntax : getNet <IP Address> <Subnet Mask>
#
set -A ADDR `echo $1 | awk 'BEGIN{FS="."}{print $1, $2, $3, $4}'`
set -A MASK `echo $2 | awk 'BEGIN{FS="."}{print $1, $2, $3, $4}'`
Octet=0
while [ "$Octet" -le "3" ]
do
let Network[$Octet]=${ADDR[$Octet]}\&${MASK[$Octet]}
let Octet=$Octet+1
done
printf "%s.%s.%s.%s\n" ${Network[*]}
Best regards,
Don Davis
Leslie Clark wrote:
> Don, did you ever find something (or write something) to do this? Want to
> share? It seems to me that it would be handy for use in T/EC rules, since
> the
> Network Unreachable event includes the network address and the mask.
>
> Cordially,
>
> Leslie A. Clark
> IBM Global Services - Systems Mgmt & Networking
> Detroit
>
> DON-N-DARLA@att.net@tkg.com on 10/09/2000 07:49:03 PM
>
> Please respond to IBM NetView Discussion <nv-l@tkg.com>
>
> Sent by: owner-nv-l@tkg.com
>
> To: nv-l@tkg.com
> cc:
> Subject: [NV-L] Determining Network Address
>
> Does anyone have a simple utility that, given an
> IP Address and the subnet-mask, determine the
> Network Address? I need to be able to do this from a
> script, using the information in the TopM Interface List
> NetView field.
>
> Don Davis
> _________________________________________________________________________
> NV-L List information and Archives: http://www.tkg.com/nv-l
>
> _________________________________________________________________________
> NV-L List information and Archives: http://www.tkg.com/nv-l
--
========================================
Don Davis - Tivoli Certified Consultant / Instructor
Alliance of Professionals and Consultants, Inc.
Phone: 919-510-9696
Visit our Web site at: http://www.apc-services.com
|