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?
shishir_sriConnect With a Mentor Commented:
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.
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.)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.