Hello *,
we use ScriptFTP with the "new" *.ok-File-Feature. Maybe you remember the problem.
Now we have the problem that we must write an ok-File if the original-File is copied correctly.
E.G:
I put a file to a remote FTP-Server:
hello.txt
After hello.txt is completely moved to FTP-Server I must write a file "hello.txt.ok", that signals that the file-transfer is completed. The remote ftp-server can now work ahead with the hello.txt-File
This problem is occured in an environment where the remote ftp-server will work ahead with the transfered file.
ScriptFTP call the name during the transfering hello.part or hello.txt.part, but the part-file is not locked from ScriptFTP. So the remote ftp-server try to rename the file to check if the transfer is completed. Normaly the files are locked from the ftp-client and cannot be renamed (file ist not transfered completely). If a rename is possible the ftp-server can work ahead with the hello.txt-File.
local Drive ----> ScripFTP (put file to) ---> remote FTP
remote FTP ----> try to rename the file or expects a *.ok-file ----> move forward in a different system
So in this case It was nice to solve the problem with locking the file during the transfer or in smarter way write an *.ok after completion the transfer. In the actual behaviour of ScriptFTP we have the problem that the remote-FTP cannot occur if the file is transfered and move the file to the Working-System twice or thrice.
Is that in any possible.
Many thanks for answering
Marc
we use ScriptFTP with the "new" *.ok-File-Feature. Maybe you remember the problem.
Now we have the problem that we must write an ok-File if the original-File is copied correctly.
E.G:
I put a file to a remote FTP-Server:
hello.txt
After hello.txt is completely moved to FTP-Server I must write a file "hello.txt.ok", that signals that the file-transfer is completed. The remote ftp-server can now work ahead with the hello.txt-File
This problem is occured in an environment where the remote ftp-server will work ahead with the transfered file.
ScriptFTP call the name during the transfering hello.part or hello.txt.part, but the part-file is not locked from ScriptFTP. So the remote ftp-server try to rename the file to check if the transfer is completed. Normaly the files are locked from the ftp-client and cannot be renamed (file ist not transfered completely). If a rename is possible the ftp-server can work ahead with the hello.txt-File.
local Drive ----> ScripFTP (put file to) ---> remote FTP
remote FTP ----> try to rename the file or expects a *.ok-file ----> move forward in a different system
So in this case It was nice to solve the problem with locking the file during the transfer or in smarter way write an *.ok after completion the transfer. In the actual behaviour of ScriptFTP we have the problem that the remote-FTP cannot occur if the file is transfered and move the file to the Working-System twice or thrice.
Is that in any possible.
Many thanks for answering
Marc
Hi Marc,
I think that the other possibility (upload a *.ok file after upload) could be done. The way to do so is using the FOREACH loop and, after a file is uploaded, create a *.ok file locally and then upload it. It's only a sketch, let me know your thoughts:
So in this case It was nice to solve the problem with locking the file during the transfer or in smarter way write an *.ok after completion the transfer.The FTP protocol does not provide a way to lock files, there is no FTP protocol command for that. But, as far as I know, the FTP servers must lock the files that are being uploaded to prevent other processes accessing corrupt or incomplete data (your case). Some FTP servers, instead of locking the files, receive them in a temporary directory and once the upload is completed they copy the full transferred file from the temporary directory to it's final location. Depending on the FTP server software used (ProFTPd, filezila server, Microsoft IIS...) the bahavior can be the first one or the other, rarely the FTP server does nothing. Try checking, if possible, the FTP server configuration, there should be a switch, check box or something else for configuring this behavior.
I think that the other possibility (upload a *.ok file after upload) could be done. The way to do so is using the FOREACH loop and, after a file is uploaded, create a *.ok file locally and then upload it. It's only a sketch, let me know your thoughts:
FTP Script
- # Change current local directory
- # Retrieve the file listing, only txt files
- # Upload the file
- # Check if the upload were successful
- # Create the ok file
- $okfilename=$txtfile.".ok"
- # Download the touch command for windows from
- # http://www.codeproject.com/KB/applications/touch_win.aspx
- # Upload it
- # If the ok file was succesully uploaded, delete the local copy
liked Script FTP? Try our other product Email Parser
is it possible to name the file:
<filename>.ok instead of what the script currently does <filename.txt>.ok?
Our system looks for a filename.ok file but not to a filename.txt.ok
thanks
<filename>.ok instead of what the script currently does <filename.txt>.ok?
Our system looks for a filename.ok file but not to a filename.txt.ok
thanks
Hi Marty,
Yes, it is possible, you have to use TEXTCUT and TEXTLENGTH to remove the last three characters of the file name and then append "ok":
Note that this code works only if the file has 3 characters after the dot (most common).
The complete script would be:
Yes, it is possible, you have to use TEXTCUT and TEXTLENGTH to remove the last three characters of the file name and then append "ok":
FTP Script
- $filename="test.txt"
- $filename_ending_in_ok=$filename_without_extension."ok"
- # Should show test.ok
The complete script would be:
FTP Script
- # Change current local directory
- # Retrieve the file listing, only txt files
- # Upload the file
- # Check if the upload were successful
- # Create the ok file
- # ---------- Added
- $okfilename=$filename_without_extension."ok"
- # -----------------------
- # Download the touch command for windows from
- # http://www.codeproject.com/KB/applicati ... h_win.aspx
- # Upload it
- # If the ok file was succesully uploaded, delete the local copy
- $filename="test.txt"
- $filename_ending_in_ok=$filename_without_extension."ok"
- # Should show test.ok
liked Script FTP? Try our other product Email Parser