From owner-freebsd-questions Tue Jun 4 6:12:56 2002 Delivered-To: freebsd-questions@freebsd.org Received: from mail.groupware.uconn.edu (mail2.groupware.uconn.edu [137.99.30.57]) by hub.freebsd.org (Postfix) with ESMTP id DDF9137B400 for ; Tue, 4 Jun 2002 06:12:49 -0700 (PDT) Subject: Re: Getting network and broadcast addresses in a shell script To: freebsd-questions@freebsd.org X-Mailer: Lotus Notes Release 5.0.8 June 18, 2001 Message-ID: From: Matt.Smith@uconn.edu Date: Tue, 4 Jun 2002 09:12:49 -0400 X-MIMETrack: Serialize by Router on Mail/Servers/UConn(Release 5.0.10 |March 22, 2002) at 06/04/2002 09:12:50 AM MIME-Version: 1.0 Content-type: text/plain; charset=us-ascii Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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