From owner-freebsd-questions Mon Feb 5 12:56:10 2001 Delivered-To: freebsd-questions@freebsd.org Received: from post.mail.nl.demon.net (post-10.mail.nl.demon.net [194.159.73.20]) by hub.freebsd.org (Postfix) with ESMTP id 8B67C37B491 for ; Mon, 5 Feb 2001 12:55:49 -0800 (PST) Received: from [212.238.77.116] (helo=gateway.raggedclown.net) by post.mail.nl.demon.net with smtp (Exim 3.14 #2) id 14Psfq-0007fc-00; Mon, 05 Feb 2001 20:55:47 +0000 Received: from buffy.raggedclown.net (buffy.raggedclown.intra [192.168.1.2]) by gateway.raggedclown.net (Ragged Clown Gateway) with ESMTP id 49B5C33967; Mon, 5 Feb 2001 21:47:57 +0100 (CET) Received: by buffy.raggedclown.net (Ragged Clown Mailhost, from userid 500) id 1F93812C4E; Mon, 5 Feb 2001 21:47:14 +0100 (CET) Date: Mon, 5 Feb 2001 21:47:14 +0100 From: Cliff Sarginson To: Joe.Warner@smed.com Cc: lucas@slb.to, freebsd-questions@FreeBSD.ORG Subject: Re: Help me make FreeBSD shine Message-ID: <20010205214713.A1054@raggedclown.net> References: <852569EA.005F58D2.00@Deimos.smed.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <852569EA.005F58D2.00@Deimos.smed.com>; from Joe.Warner@smed.com on Mon, Feb 05, 2001 at 10:25:14AM -0700 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Mon, Feb 05, 2001 at 10:25:14AM -0700, Joe.Warner@smed.com wrote: > > > Hey thanks! > > Right now, I'm just starting with something simple. > > I created this script: > > #!/bin/sh > > grep -v "#" /etc/hosts | awk '{print $1}' | while read host > do > ping -c 1 $host > done >results ^^^^^^^^ > > > ...and it works, except I want the output to be dumped > into a text file. > > Do you know how I should change this script so I could > do that? > > If this script doesn't do what my manager wants, I'll > definitely try yours. > > Thanks > > Joe > > > > > > > > > |--------+-----------------------> > | | Lucas Bergman| > | | | | > | > | | | > | | 02/05/01 | > | | 09:50 AM | > | | Please | > | | respond to | > | | lucas | > | | | > |--------+-----------------------> > >---------------------------------------------------------| > | | > | To: Joe Warner/SMS@SMS | > | cc: freebsd-questions@freebsd.org | > | Subject: Re: Help me make FreeBSD shine | > >---------------------------------------------------------| > > > > > > > Is there a way that I could write up some simple shell script that > > would ping the IP addresses of these systems and then log the output > > into a file that I could make accessible through a web browser? If > > so, I could set it to run in the CRON scheduler every four hours at > > specific times/days. > > Look at > > http://www.slb.to/~lucas/hacks/iplist-1.0.tar.gz > > This contains two scripts, iplist.sh and iplist2html.sh. The first > pings all the IP addresses on an 8-bit IP network and logs when each > was last heard from (in Unix time format, seconds since midnight on > 19700101). The second script creates a web page that shows which IP > addresses are "free" (have not been heard from in greater than some > number of seconds, by default twenty days). This helps out my old > employer who refused to use DHCP but who wanted an easy way to assign > free IP addresses. > > The package also contains a trivial C program which prints the current > time in seconds since the Unix epoch. > > I have a cron job that runs `sh /path/to/iplist.sh' every few hours > and `sh /path/to/iplist2html.sh >/path/to/freeip.html' afterward. I > would advise *not* running these scripts as root. Also, ideally you > would run `sh iplist2html.sh >freeip.html.tmp && mv freeip.html.tmp > freeip.html' so that freeip.html isn't truncated if iplist2html.sh > bombs in the middle of a run. iplist.sh does not corrupt its data > file if it crashes. > > Hopefully, this is similar enough to what you want to do that it will > get you started. > > Lucas > > > > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-questions" in the body of the message To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message