Link to home
Start Free TrialLog in
Avatar of Sudhagar Rajaraman
Sudhagar Rajaraman

asked on

Python or perl or ruby script for automate file processing -help

Hi All ,

Im looking for a python or perl or ruby script with automate file processing

I have a folder where files drops in unique name continously from webserver ( depend on user upload ) as

Example : Folder contain

file1.cap
file2.cap
.
.
.
Filen.cap

I need scirpt to take new file dropped in that folder and proccess this command in termial

/opt/svr/run.sh -f /Path=/opt/filedropfolder/filen.cap /log=/opt/svr/log/filen.log

Note : (filen.cap and filen.log need to change according to file drop)

Thanks in advance
Avatar of gelonida
gelonida
Flag of France image

after the command has been run for the file.
Will  the file be deleted from the folder?

In other words how do you know whether a file was already treated or not?
The answer to this question impacts the correct answer / best solution.

I'd suggest a solution using python and the library watchdog if you can install it.
watchdog can watch a diretory for changes and launch actions.
you could use subprocess.Popen() to call the command you'd like to execute.
Another important question:
Can I be sure, that the files, that are in this folder are always complete?

Or could it happen, that if a file is uploaded slowly I would encounter an incomplete file.
How would your commands react if they receive an incomplete file.
Some web frameworks avoid the above mentioned problem by uploading to a temp directory and moving only to the destination folder when the file is completely uploaded.
ASKER CERTIFIED SOLUTION
Avatar of wilcoxon
wilcoxon
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
Do the files appear strictly in sequence? I'm wondering if, for instance, file3 exists then can we be sure file2 is complete? (but not necessarily file3, if that is the highest number).
Also, under what condition do the numbers reset? (if they ever do)
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I have recommended this question be closed as follows:

Accept: wilcoxon (https:#a40902277)

If you feel this question should be closed differently, post an objection and the moderators will review all objections and close it as they feel fit. If no one objects, this question will be closed automatically the way described above.

suhasbharadwaj
Experts-Exchange Cleanup Volunteer