Microsoft's FTP is able to automate ftp tasks with the scripting function. The problem is, that FTP does not tell you by means of a return code (errorlevel)whether there were any errors during the execution of the script.
This is what FTP-LA is for. It analyzes the redirected output of the FTP script for ftp error codes (4xy, 5xy). Seperately checked (and counted as errors) are the missing of a correct login (code 230) and the missing of a normal end of the ftp session (code 221).
FTP-LA returns following errorlevels:
Errorlevel 0: No errors found
Errorlevel 1: Errors found in FTP logfile
The batch file to use FTP-LA with would look about like this:
@echo off
ftp %1 %2 %3 %4 %5>%temp%\ftp.log
ftp-la %temp%\ftp.log
if not errorlevel 0 goto ok
echo There was an error during the execution of the FTP script
goto end
:ok
echo FTP script was executed successfully
:end
Redirecting the output has the disadvantage that you do not see what is going on in the ftp process. To overcome this problem, use my (or some other) TAIL program.
The batch file would then look about like this:
@echo off
echo.>%temp%\ftp.log
start tail %temp%\ftp.log 100
ftp %1 %2 %3 %4 %5>>%temp%\ftp.log
ftp-la %temp%\ftp.log
if not errorlevel 0 goto ok
echo There was an error during the execution of the FTP script
goto end
:ok
echo FTP script was executed successfully
:end