File size using FTP

Hi,

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?

Thank you!

regards,
Constantin

hi Constantin,

There is probably a good answer for why your get is failing. That would be the better alternative then checking the size of the file.

But if you are looking for a work-around, try using the ftp:quote service. It executes a given FTP command.

You could use the SIZE remote-filename FTP command to identify the size of the file before processing.

HTH,
Cort

hi Cort,

It is working fine with size command. Thank you!

regards,
Constantin

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.

pub.ftp:quote

I have passed input as ---- dir twn_mot

But it is giving, the following output

← 500 ‘DIR’: command not understood.

Hi Reamon, please advice

dir is not an FTP command. Use ls.