Sample Windows 2008 batch script : test status of files transfer & retransfer if status fails
Posted on 2013-01-13
In one new project, our Win 2008 (client) ftp scripts had been failing
intermittently & the network chaps can't isolate where on the
network is the 'disconnect' happening. Sometimes, files at the
remote ftp server end are locked or not there yet (ie apps at remote
end delayed by a couple of minutes in creating the data file).
In ncftp, there are various status codes that we can test for:
These are the errorlevel values returned by ncftpget:
ncftpget returns the following exit values:
1. Could not connect to remote host.
2. Could not connect to remote host - timed out.
3. Transfer failed.
4. Transfer failed - timed out.
5. Directory change failed.
6. Directory change failed - timed out.
7. Malformed URL.
8. Usage error.
9. Error in login configuration file.
10. Library initialization failed.
11. Session initialization failed.
My customer does not allow us to use opensource tools but
only Windows native ftp client, thus I'll a way to test if a
file get (or mget)'s status & if it fails, to pause for 10 mins
(doing 'ping localhost -n 600 > nul' would do as 1 ping is
abt 1 sec) & attempt retransfer again & if it fails attempt
again a 3rd time.
Will need some sample Windows batch script as I don't
quite know the syntax to check the %errorlevel% for