i need to remove the file from MT only after successful transfer. if ftp can not be done for network trouble or remote server is down , the file will not be removed from MT
By “MT” I am guessing you mean the router?
So you are uploading a file to a FTP server and only want to delete it if the transfer was successful, right?
An easy way to test if it showed up at the FTP server would be to attempt a download. But that only works if the destination file only exist after a successful transfer.
This should work:
(You may be able to remove the “:delay 5” calls, but they are nice to have in case something is a little slow on the FTP server.)
Another, and maybe prettier way to do it, would be to use the API to delete the file from the router when the FTP server has successful received the file.
This can be done with something like this:
/file/print
=.proplist=.id
?name=<filename>
<save the .id you receive in the reply>
/file/remove
=.id=<.id>
Of course that depends on what you are doing with the file once you receive it and if you are able to contact the router via the API at all.
If the script fails and stops executing when the FTP upload fails, then what was the issue to begin with?
But yeah, my script was the only way I could think of to check if the FTP server has the file.