Link to home
Start Free TrialLog in
Avatar of rleyba828
rleyba828Flag for Australia

asked on

How to run a bash/perl script that gets triggered when a file has been received in a directory

Hi Team,

  I have a requirement wherein a third party machine will be SCP-ing  a log file into a user directory on my mySQL server.   I need a mechanism wherein if the file "arrives" it would kick off a script that would process the log file and eventually upload it to my MySQL database.

  While google searching,  I keep stumbling on "inotify" and "fschange".   In my case, it looks like inotify is simpler to implement,...although for my very simple requirement, even  a regularly firing (1 minute interval) cron job will do.

  The problem with the inotify google searches i stumble into is that they just keep referencing the same inotify syntax and no one actually gives a real world example of how to use it.

In my application, the received file could be quite large and could take up to a minute to transfer over, so I need a script that actually checks to see if the file stops growing....and then...start parsing it.

  Any suggestions on how I can implement this would be much appreciated.

  Thanks very much.

ASKER CERTIFIED SOLUTION
Avatar of wesly_chen
wesly_chen
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Have you considered using an email pipe?
Avatar of rleyba828

ASKER

Hi Wesly,

   Thanks for this.  I will try out your script when I get home tonight so I can test on some LAB machine. I will update you with what I find.

Ray,

   I searched for some links on e-mail pipe.   In our situation though, the receiving box is behind a firewall and is not designed to receive e-mails or have an e-mail account set.  They are allowing inbound ssh only, unfortunately.  But thanks for the idea.