From owner-freebsd-questions@FreeBSD.ORG Sun Feb 6 22:39:42 2011 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 797D21065695 for ; Sun, 6 Feb 2011 22:39:42 +0000 (UTC) (envelope-from j65nko@gmail.com) Received: from mail-yi0-f54.google.com (mail-yi0-f54.google.com [209.85.218.54]) by mx1.freebsd.org (Postfix) with ESMTP id 333608FC3B for ; Sun, 6 Feb 2011 22:39:41 +0000 (UTC) Received: by yie19 with SMTP id 19so1609650yie.13 for ; Sun, 06 Feb 2011 14:39:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=YDO0+L3PgYZF4873Cdr0ReTyRRCOqY/4hgigntEiBcg=; b=MduE9vfz9HdxGmxZHqBmbrmiuarRbkxHNCSm6rovQj3NknjBdWU9o9FA2BZpU1bAac 3IPIl6gL1igqnl2GxtJeo5i4IWMRFw1GlMsr1WOWQ26qriJG5acU2ir8ll02BL40+FK0 7CG6g9Au7mIZbETzPjjn2WPl5bS4RPHB0Uk94= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=UirNlRw1wAWfrARRUbJiCTVs0vvYeyQX6g6Lnb2AAyhm/tmBB145QEVepVjIpozMJr tNf2HC2h+mbgXbvXiggawfPmbVTJ4nC8aXwsidDSwgRE8YcqegrR6R+0U2GHMkNZQcwP 2FdwKbeZ2GemnL+NwfhFQhpsdOKkoSu+1VfAM= MIME-Version: 1.0 Received: by 10.90.63.14 with SMTP id l14mr11754672aga.185.1297030570323; Sun, 06 Feb 2011 14:16:10 -0800 (PST) Received: by 10.90.120.4 with HTTP; Sun, 6 Feb 2011 14:16:10 -0800 (PST) In-Reply-To: <12dfb2d663e.8735497800158401667.-7202521450009428314@zoho.com> References: <12dfb2d663e.8735497800158401667.-7202521450009428314@zoho.com> Date: Sun, 6 Feb 2011 23:16:10 +0100 Message-ID: From: J65nko To: kellyremo Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: FreeBSD Subject: Re: if the file changes send email about diff X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Feb 2011 22:39:42 -0000 On Sun, Feb 6, 2011 at 2:33 PM, kellyremo wrote: > > I have 2 script. Script "A", Script "B". > > Script "A" is regulary watching the "dhcpacks" [dhcp release is configure= d to 2mins] in the logs, for the past 2 minutes. it writes the MAC addresse= s to a file [/dev/shm/dhcpacks-in-last-2min.txt] every 2 minutes. Ok, this = is working, active clients are in this file. Super! > > Script "B": http://pastebin.com/raw.php?i=3DwvhwhPWu > I'm trying to create a script, that watches the changes in "/dev/shm/dhcp= acks-in-last-2min.txt" file [in every 1 sec]. Ok. But: my "watcher" script = [the pastebined] is not working fine...sometime it works, sometime it send = that someone "XY logged out", but it's not true! nothing happened, and the = problem is not in the Script "A". > > Can someone help me point out, what am i missing? How can i watch a file = [in every sec], that contains only MAC addresses, and if someone doesn't ge= t dhcpack in 2 minutes, the file "/dev/shm/dhcpacks-in-last-2min.txt" chang= es, and that clients MAC address will be gone from it, and i need to know, = who was it [pastebined my script..but somethings wrong with it]. You are attempting to re-invent the wheel called "revision control system" ;) Your FreeBSD box has a simple revision control system called 'rcs'. It will do the most things you are trying to emulate in your shell script. Read the rcsintro(1) man page how to get started.