 |
SoftTree Technologies
Technical Support Forums
|
|
Author |
Message |
fullingdale
Joined: 25 Nov 2008 Posts: 3 Country: United Kingdom |
|
Renaming Files during FTP Upload |
|
I wonder if someone could help with some script.
I am uploading a file to an FTP using 24x7 Scheduler and want to rename it during the process.
For example the local file is called TEST.XML
I need to rename that to TEST.TMP or TEST.XML.TEMP
Then FTP it.
Finally, when it's complete, rename it back to TEST.XML
My present script looks a little like the following (obviously altered so as not to show confidential info).
 |
 |
Dim file_list, string
Dim short_file_name, string
Dim ftp_file_name, string
Dim local_file_name, string
Dim archive_file_name, string
Dim no_more, boolean
DIm tmp,string
// Search files on FTP server.
Dir "Z:\\PATH\\FOLDER\\*.*", file_list
isEqual file_list, "", no_more
IfThen no_more, DONE
// Upload file(s) to FTP server.
LoopUntil no_more, END_LOOP
GetToken ",", file_list, short_file_name
Concat, "REMOTEDIR", short_file_name, ftp_file_name
Concat, "Z:\\PATH\\FOLDER\\", short_file_name, local_file_name
FTPPutFile "FTPIP", "USER", "PASSWORD", local_file_name, ftp_file_name
Concat, "Z:\\PATH\\FOLDER\\DONE\\", short_file_name, archive_file_name
FileMove local_file_name, archive_file_name
isEqual file_list, "", no_more
END_LOOP:
DONE: |
Any help, appreciated.
|
|
Tue Nov 25, 2008 9:24 am |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7949
|
|
|
|
Hi. Local and remote files can have different name. On a first look your script looks ok. If it doesn't work, please enable tracing options, rerun the job and post a trace of the job execution so we can pinpoint what goes wrong.
|
|
Tue Nov 25, 2008 9:51 am |
|
 |
fullingdale
Joined: 25 Nov 2008 Posts: 3 Country: United Kingdom |
|
|
|
Ah, you have missed what I am after ... there's a service which watches the FTP site for incoming XML files ... but it's polling so often that it's collecting the files, before this script has finished uploading them.
Hence needing to rename the file while the upload is taking place.
Hope that makes sense.
|
|
Tue Nov 25, 2008 10:04 am |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7949
|
|
|
|
Maybe you are thinking about use of FTPRenameFile, but you didn't say that :)
I guess you can first upload XML files with non-XML extensions to the FTP server, then rename them after the upload is complete.
ConcatEx "REMOTEDIR", short_file_name, ".TMP", ftp_file_name_tmp
...
FTPPutFile ...
FTPRenameFile ... , ftp_file_name_temp, ftp_file_name
...
--- by the way, commas aren't needed after Concat keyword
|
|
Tue Nov 25, 2008 8:50 pm |
|
 |
fullingdale
Joined: 25 Nov 2008 Posts: 3 Country: United Kingdom |
|
|
|
Spot on, thanks!
I guess that this is something that I should have known, but yesterday was my first time using 24x7 and was snowed under with thing to do.
Many thanks for the answer!
|
|
Wed Nov 26, 2008 3:27 am |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|