Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: monitoring directory for new subdirectories

by CSJewell (Beadle)
on Mar 27, 2009 at 23:00 UTC ( [id://753798]=note: print w/replies, xml ) Need Help??


in reply to monitoring directory for new subdirectories

That seems a little "brute-force", but other methods will depend on the OS: Win32, Mac/Unixy, or who-knows-what? I'll admit not knowing about anything but Win32 on that level.

Win32 provides monitoring API calls (FindFirstChange(), FindNextChangeNotification() and SHChangeNotifyRegister() all look like things to try.) You may have to code that part in XS, and other people would have more knowledge about specifics than I would (I remember using the FindXChangeNotification API calls in a C++ program a few years back.)

  • Comment on Re: monitoring directory for new subdirectories

Replies are listed 'Best First'.
Re^2: monitoring directory for new subdirectories
by incognito129 (Acolyte) on Mar 27, 2009 at 23:06 UTC
    the script is running in debian 4.0

      Linux::Inotify2.  Some sample code to get you started: Inotify2 findings.

      Update: more (and specific) sample code:

      #!/usr/bin/perl use Linux::Inotify2; my $inotify = Linux::Inotify2->new() or die "unable to create new inotify object: $!"; $inotify->watch( "/tmp", # directory to watch IN_CREATE, # flags sub { # callback routine my $evt = shift; my $name = $evt->fullname; if (-d $name) { print "directory $name has been created\n"; } } ); 1 while $inotify->poll; __END__ $ stty -tostop # just in case $ ./753790.pl & [1] 2590 $ mkdir /tmp/somedir directory /tmp/somedir has been created $
        any other options? Make fails for Linux::Inotify2 on my system, not sure why.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://753798]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (3)
As of 2025-04-19 04:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.