MS-DOS FTP command in batch file: raise error

In MS-DOS (Windows 2003 R2 Server), I have a batch file that has an FTP command, for example: -

FTP.CMD
-------
cd d:\extracts\scripts
ftp -i -s:ftp_getfile.ftp
exit

I would like the batch file to raise and return error level 1 for failure instead of 0, so that the calling batch file can handle it.

The error may be caused by the absence of an FTP server. Nothing is returned right now to indicate an error condition has occurred.

Please can anyone advise?

Thank!:)

+3
source share
2 answers

, , . script , FTP script. , FTP, , "". ftp ftp.inp, FTP , '-s'.

ftp -s:ftp.inp > ftp.log

find /I /C "not connected" ftp.log
IF NOT ERRORLEVEL 1 GOTO FTPERROR

find /I /C "not found" ftp.log
IF NOT ERRORLEVEL 1 GOTO FTPERROR

find /I /C "failed" ftp.log
IF NOT ERRORLEVEL 1 GOTO FTPERROR

REM --- no errors found
GOTO :END

:FTPERROR
REM --- error found

:END
+2

: ftp ?

FTP Windows ( PASV) .

NcFtp. , , .

+1

All Articles