Operating System - Linux
1828961 Members
2223 Online
109986 Solutions
New Discussion

Preventing access to a file being FTP'd

 
SOLVED
Go to solution
TheJuiceman
Super Advisor

Preventing access to a file being FTP'd

Here is what I'm wanting to do...
I have a process that FTP's a large file from a windows box to a HP-UX box. In fact there are a lot of FTP processes that occur fairly frequent in this fashion.
I have a job scheduled to run very frequently on the HP box that will grab any FTP'd file in the depository directory and process it.
Problem: How do I tell the process on the HP box to wait until the FTP process is complete before accessing the file?
6 REPLIES 6
Hein van den Heuvel
Honored Contributor
Solution

Re: Preventing access to a file being FTP'd

I find it best to transfer the file using a temporary output name and rename to the looked-for name on succesful transfer.

You indicate 'any' FTP'd file though.
Can that be change to any file not named .transfer or .tmp ?

Or can you use a subdirectory or parallel directory during the transfer, moving when done?


hth,
Hein.
F Verschuren
Esteemed Contributor

Re: Preventing access to a file being FTP'd

The reaname of the file is a simple solution....

In the kernal when a file closes (so if the write is done) ther will be a trigger.
randevou router eamons pickup this singal to be sure the write is done. this is alsow a lot of work to program.

the easey way is to either use the rename (but not all ftp jops can do this nicely) ore use a extra trigger file that you put on the hp box after you pleased the large file.. if your job sees the trigger file it has to remove the trigger and does the job...
Matti_Kurkela
Honored Contributor

Re: Preventing access to a file being FTP'd

By the way, this is called (especially in database circles) a problem of _atomicity_.

"Atomic" means "indivisible" in this context.

From the viewpoint of the process that accesses the transferred files, the transfer must be an atomic operation: it must be either completely and successfully done, or it must be completely NOT done (i.e. a file must not exist at the expected location).

Moving a file within the same filesystem (or, as a special case, renaming the file) is guaranteed to be an atomic operation at the operating system level. The solutions outlined by Hein exploit this property.

MK
MK
Dennis Handly
Acclaimed Contributor

Re: Preventing access to a file being FTP'd

I thought ftp when transferring files gives the file no access permissions? And this is only changed when done.
Arturo Galbiati
Esteemed Contributor

Re: Preventing access to a file being FTP'd

Hi,
another possibility is to FTP 2 file, the real data file and a flag file and start your process only when the flag file arrives.
In this way you will be sure tocatch teh data file completed. To avoid to chnage your script you can create a new one that run the origianl script only when the flag file is present. Just my .02$ based on a same problem in the past.
HTH,
Art
TheJuiceman
Super Advisor

Re: Preventing access to a file being FTP'd

Thanks everyone for the suggestions.