How can I test whether a csv file is currently open and being written to - the file, not a file hand

Posted by Henry on Stack Overflow See other posts from Stack Overflow or by Henry
Published on 2010-05-25T15:39:35Z Indexed on 2010/05/25 15:41 UTC
Read the original article Hit count: 232

Filed under:

I've seen a few questions/answers here that deal with this, but none really give me an answer/solution.

I've got a Clipper system writing csv files to a Windows directory. I have a perl script running on a Linux server that is reading a mount of that Windows directory and importing the files to a database.

Right now we're using flag files to indicate when a csv is no longer being written to; the flag files gets written after the csv is done. I'd really rather just get what I need from the csv itself, but I can't seem to find a way to tell when the file is open and being written to.

lsof doesn't seem to answer my need. I've tried using flock and open the file with an exclusive lock, thinking it might throw an error if the file is being modified, but it doesn't.

Any thoughts?

© Stack Overflow or respective owner

Related posts about perl