public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Adam Kropelin <akropel1@rochester.rr.com>
To: Prakash Punnoor <prakashp@arcor.de>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Robert Love <rml@novell.com>
Subject: Re: [patch] inotify for 2.6.11
Date: Tue, 5 Apr 2005 23:21:25 -0400	[thread overview]
Message-ID: <20050405232125.A18969@mail.kroptech.com> (raw)
In-Reply-To: <4252C8D8.9040109@arcor.de>

I've been meaning to play with inotify for a while now and finally made
time for it tonight. I'm not much of a GUI guy, so I'm mostly interested
in exploring the command line applications of inotify --i.e., what sort of
havoc can I wreak with it in a script.

To that end I sat down tonight a threw together a simple command line
interface. Before I tell you where the code is, please note that I wrote
it while half asleep and more than a little high on cough syrup, so it's
undoubtedly chock full of buffer overflows, infinite loops, segfaults,
and other gremlins just waiting to eat your data, so PLEASE FOR THE LOVE
OF MIKE don't use it on, around, under, or in the general vicinity of,
anything important.

    http://www.kroptech.com/~adk0212/watchf.c

The basic usage is...

    watchf [-i] [-e<events>] <file-to-watch> [-- <command-to-run>...>]	

        -i says stay in an infinite loop, don't exit after one event
	-e gives the list of events to wait for (see the code)
	<file-to-watch> is the file or directory to be watched
	Everything after -- is taken as a command to run each time an
	event ocurrs with any ocurrences of {} being replaced with the
	name of the affected file, as returned in the inotify_event
	structure.

So what's it good for? Well, besides making fun of my coding skills,
it can be used to watch a directory and run a command when something
changes. For example, a one-line auto-gzip daemon that will haul off and
gzip anything you drop into ./gzipme:

    watchf -i -eWT gzipme -- gzip gzipme/{}

Where to go from here? The code is relatively half-baked at the moment,
but I imgaine this could be turned into a relatively useful generic
tool. For example, it should send the filename to stdout and return the
event mask when in single-shot mode. That would make it useful as part
of a longer pipeline.  You should be able to use it to wait for a specific
file to be created --although that will be interesting if one or more 
segments of the path don't exist yet.  Ultimately I'd like to get rid of
the <command-to-run> argument(s), but I can't think of any way to do it
that isn't going to end up missing events.

--Adam


  parent reply	other threads:[~2005-04-06  3:14 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-04 18:37 [patch] inotify for 2.6.11 Robert Love
2005-03-04 19:11 ` [patch] inotify for 2.6.11-mm1 Robert Love
2005-03-07  1:19   ` Christoph Hellwig
2005-03-07  1:38     ` Andrew Morton
2005-03-07 21:27     ` [patch] inotify for 2.6.11-mm1, updated Robert Love
2005-03-08  4:40       ` Christoph Hellwig
2005-03-08  4:50         ` Robert Love
2005-03-08 17:08           ` Robert Love
2005-03-04 21:38 ` [patch] inotify for 2.6.11 Timothy R. Chavez
2005-03-04 21:40   ` Robert Love
2005-03-06  0:04 ` Christoph Hellwig
2005-03-06  0:40   ` Robert Love
2005-03-07  1:23     ` Christoph Hellwig
2005-03-07  4:33       ` Robert Love
2005-03-07 21:25 ` [patch] inotify for 2.6.11, updated Robert Love
2005-04-05  7:58 ` [patch] inotify for 2.6.11 Prakash Punnoor
2005-04-05 16:12   ` Robert Love
2005-04-05 17:20     ` Prakash Punnoor
2005-04-05 17:35       ` Robert Love
2005-04-05 22:09       ` Robert Love
2005-04-06  3:21       ` Adam Kropelin [this message]
2005-04-10 16:16 ` Erik Meitner
  -- strict thread matches above, loose matches on Subject: below --
2005-03-07  3:13 Albert Cahalan
2005-03-08  1:00 ` Arnd Bergmann
     [not found] <3EqlI-2DI-59@gated-at.bofh.it>
     [not found] ` <3PRs6-89U-15@gated-at.bofh.it>
     [not found]   ` <3PYWC-636-7@gated-at.bofh.it>
     [not found]     ` <3Q0F6-7Ar-37@gated-at.bofh.it>
     [not found]       ` <3Q4z0-2tA-15@gated-at.bofh.it>
     [not found]         ` <pan.2005.04.06.00.53.44.705260@intel.com>
2005-04-06  1:21           ` Robert Love
     [not found] <3Q7wT-4HJ-11@gated-at.bofh.it>
     [not found] ` <3Q7wT-4HJ-13@gated-at.bofh.it>
     [not found]   ` <3Q7wT-4HJ-15@gated-at.bofh.it>
     [not found]     ` <3Q7wT-4HJ-17@gated-at.bofh.it>
     [not found]       ` <3Q7wT-4HJ-19@gated-at.bofh.it>
     [not found]         ` <3Q7wT-4HJ-21@gated-at.bofh.it>
     [not found]           ` <3Q7wT-4HJ-9@gated-at.bofh.it>
     [not found]             ` <pan.2005.04.08.01.37.42.462474@intel.com>
2005-04-08  1:52               ` Robert Love

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050405232125.A18969@mail.kroptech.com \
    --to=akropel1@rochester.rr.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=prakashp@arcor.de \
    --cc=rml@novell.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox