I have a service which get a file using ftp package.
I have a problem with some files which are opened and the get service is never ending.
How can I identify the open files before trying to get them ?
All this open files are having 0 bytes, is there a way to get the file length inside ftp?
I agree with Cort that checking the filesize is probably masking another problem. You really should investigate why the get of the file is failing. My suspicion is that the file is locked by the process that is writing the file–thus you can see it via ls but you can’t get it.
If this is the case, you might consider changing the interaction. The process that is writing the file should use a particular name pattern, such as *.tmp when writing. When the write is done, it renames the file to another pattern, such as *.dat. (Renames are atomic operations which either completely succeed or fail and no locks can exist on the file.) Your process then does ls and get for *.dat and will never try to retrieve a partial or locked file.