Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 4 Jun 2002 09:12:49 -0400
From:      Matt.Smith@uconn.edu
To:        freebsd-questions@freebsd.org
Subject:   Re: Getting network and broadcast addresses in a shell script
Message-ID:  <OF13A0E481.2155BCC3-ON85256BCE.00483BCA@groupware.uconn.edu>

next in thread | raw e-mail | index | archive | help



On Tue, 4 Jun 2002, BSD Freak wrote:

> Hi all,
>
> I have the following shell script I am writing in which I need to get
> the $network and $broadcast:
>
> #!/bin
> netmask=255.255.255.0
> ip=192.168.0.1
>
> network=`do some magic with $netmask and $ip`

magic logic: network= ip && netmask, broadcast= network || ~netmask

magic code:  well -- I guess you'll have to roll-your-own for that one --
not too hard in C  or Perl.

> broadcast=`do some more magic with $netmask and $ip`
>
> echo $network
> echo $broadcast
>
> Can anyone help me with the magic?

hope that helps!
-Matt

Matthew J. Smith
matt.smith@uconn.edu
University of Connecticut ITS



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?OF13A0E481.2155BCC3-ON85256BCE.00483BCA>