2

I have a directory that gets written to when other machines send files via FTP. I want to put something in place that notices when files arrive and if their file name contains a particular substring (like "jpg"), move the file to some other directory (only after the file has finished arriving, not before)

I want to put this in place on many different kinds of Linux boxes. One such box has Linux kernel 2.4.22. It is possible there are older ones. I'm still checking.

On the older machines, I see this: inotifywait: command not found.

I've also seen this: The inotify API is available in Linux 2.6.13 and later

And this: bash: watch: command not found

Ideas in POSIX sh or bash or C could work. Perl and Python are probably not available everywhere I want to run this. I don't have permission to install packages.

user1011471
  • 179
  • 1
  • 8

1 Answers1

3

I wrote this Perl program a long time ago that could get you started if you understand it. It uses uses the inotify feature in the kernel.

http://www.win2ix.ca/2013/05/31/606/

You'll have to change the code from synchronization to doing whatever you need, but it's mostly all there.

I know you have a problem with Perl, but I wanted to give this to you just in case.

If it helps, here's a demo on how to do it with C

http://man7.org/tlpi/code/online/diff/inotify/demo_inotify.c.html

Ryan Babchishin
  • 6,160
  • 2
  • 16
  • 36