How to check if the files are done/ready to be processed


I have a few files that I am FTPing to different remote server.  My Perl script is running in background to see all the files in the directory are ready to be processed.  Is there a Perl way to check if they are ready?  I searched it such as checking file size every N seconds but cannot find a definite answer.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Why not simply call the file processing script after the FTP processs is completed?
perlwhiteAuthor Commented:
Script will be called before FTPing.  

simply to automate the process and not having to monitor the files every time.  (There will be a lot of transactions everyday.)
Some systems use a different file extension for files that are being uploaded. Eg: filename.txt.ext

Once the file upload is complete, the '.ext' will be removed.

So, in this case, your perl script can simply scan the directory for new txt files.


Alternatively, if you do not have control over your FTP server, you can write your perl script to poll all files periodically. If the file size soes not change in 5 or 10 seconds, you know that the transfer is complete; else, the file is still being uploaded.

In this case, you can write your script to work with the oldest files first, so as to minimize interaction with files that are still being transferred.


Another method (If you have control over the client machines), would be to upload to another directory like 'root/partial/', and move the files to the completed uploads folder by renaming them once the transfer is complete.

So, in this case, your perl script can simply scan the directory for new files.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.