How can my Linux daemon find out when a Windows program stopped writing a file that I got access to through SAMBA?

I am developing a system that interacts with the USPS delivery package called Dazzle. Part of this system includes a monitoring daemon, the purpose of which is to create table-shared values โ€‹โ€‹files, turn them into XML, recognized by Dazzle, and pass them to Dazzle to generate labels. And this part works fine. However, I also want to parse the output file that Dazzle creates and imports into the database.

Please note that Dazzle works on Windows. My monitoring daemon is written in Perl and runs on Linux. My Linux system has Dazzle input and output directories mounted via Samba.

Between the time, Dazzle begins to record the output file and its completion time. I want to know how I can wait for Dazzle to finish writing the output file? I tried to open the file and make it flock($fh, LOCK_SH)on it, but it did not seem useful to you.

EDIT . I have an idea based on the "mobrule" comment below. Dazzle writes the output file to XML. Each package in the package is enclosed in tags, and the entire document is enclosed in a tag. So, if I start reading the file before it is completed, I can just wait for the corresponding closing tag before taking action.

In addition, I must mention what I am currently doing. When I discover that an XML output file has been created, I try to parse it. If this parsing failed, I sleep and try again. If this fails, I sleep twice and then try again and so on. This works very well when testing with a 64 second timeout.

+5
source share
4 answers

There is no general and portable way to find out if a process has an open file descriptor for some arbitrary file. You must judge your local knowledge of the situation.

Windows, , "Dazzle". , , , "Dazzle 20 , " " Dazzle , . , , 10 , , Dazzle ".

, Dazzle . , Dazzle - . perldoc seek, " tail -f". , Dazzle .

, , , Dazzle , - , EOF.

+5

, , , , , .

+1

w/LOCK_EX - , , . , , . , Dazzle - /, .

+1

Perhaps you can write a dazzle file for a dummy file or flag (it can contain everything you need, such as a date / time stamp or serial number) to indicate that Dazzle has finished writing the file. Then all you do is check for the presence of this file to know that it is complete.

+1
source

All Articles