How to monitor changes in a directory

  • Thread starter Lorenzo Thurman
  • Start date
L

Lorenzo Thurman

I want to monitor a directory for changes, but I don't want to poll
periodically to see if anything has changed. Is there a way to get
notifications in Perl about changes to a particular directory.
TIA
 
M

micmath

Lorenzo said:
I want to monitor a directory for changes, but I don't want to poll
periodically to see if anything has changed. Is there a way to get
notifications in Perl about changes to a particular directory.
TIA

This isn't really a problem that Perl alone can solve. Essentially you
must poll and there are a few ways to do that. crontab
http://en.wikipedia.org/wiki/Crontab can be used on Unixish systems to
schedule a script (Perl or otherwise) to run periodically and scan a
directory, for example.

On some systems, like Mac OS X, you can use "folder actions"
http://www.apple.com/applescript/folderactions/ to cause an AppleScript
to run whenever a folder is modified. There may be something similar on
Windows, I'm not sure.

In any case you will need to use something in addition to perl, and
that will be dependent on your OS.
 
B

Ben Morrow

Quoth Lorenzo Thurman said:
I want to monitor a directory for changes, but I don't want to poll
periodically to see if anything has changed. Is there a way to get
notifications in Perl about changes to a particular directory.

This depends on your OS. Under Win32 there is the Win32::ChangeNotify
module; I've never used it so I don't know how well it works. Under some
versions of IRIX and Linux you can run famd and use SGI::FAM. Under some
versions of Linux you can use the Linux::Inotify or Linux::Inotify2
modules.

Ben
 
X

xhoster

Lorenzo Thurman said:
I want to monitor a directory for changes, but I don't want to poll
periodically to see if anything has changed. Is there a way to get
notifications in Perl about changes to a particular directory.

That is OS dependent. On linux, there is "fam". There seem to be some
Perl interfaces to it in CPAN, but I've never used them.

Xho
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top