Batch file 用户FTP上传确认

Batch file 用户FTP上传确认,batch-file,cmd,ftp,Batch File,Cmd,Ftp,我正在将任务从手动转移到自动 我很清楚,在执行此操作时无法检查错误,但这不是我的目标 我的代码按预期工作,但我缺少。。。某物 我需要让用户知道,在我将文件放入FTP位置后,它已上载,他们不再需要等待文件 到目前为止,我通过向用户吹嘘来做到这一点,一旦命令运行,他们就会被告知它工作了 @echo off REM Generates the script echo open 000.000.000.000> temp.txt echo username>> temp.txt ec

我正在将任务从手动转移到自动

我很清楚,在执行此操作时无法检查错误,但这不是我的目标

我的代码按预期工作,但我缺少。。。某物

我需要让用户知道,在我将文件放入FTP位置后,它已上载,他们不再需要等待文件

到目前为止,我通过向用户吹嘘来做到这一点,一旦命令运行,他们就会被告知它工作了

@echo off

REM Generates the script
echo open 000.000.000.000> temp.txt
echo username>> temp.txt
echo password>> temp.txt
echo lcd "N:\line\line\line">> temp.txt
echo put file.txt>> temp.txt
echo quit>> temp.txt


REM Open FTP and run the script above
ftp -s:temp.txt


REM Remove the temp file
del temp.txt


REM Display confirmation
msg %username% "File sent to FTP"

非常感谢您的帮助。如果需要,我将添加更多信息

您必须将文件下载回来,查看是否正确上载,然后执行
fc

要通过
ftp
下载无人参与的文件,请查看。不要忘记,当保存下载的文件时,它应该与您最初上传的文件有不同的名称

然后,只需通过如下命令比较您拥有的文件:

@echo off
fc c:\temp.txt r:\temp_to_check.txt > nul
if errorlevel 1 goto error

goto :EOF

:error
echo "The file was uploaded and downloaded incorrectly"

为了直观起见,请具体回答我的问题:

REM Open FTP and run the script above
ftp -s:temp.txt


REM File check
fc "N:\line\line\TEST.TXT" "N:\line\line\check_location\TEST.TXT" > nul
if errorlevel 1 goto error


REM Remove the temp file
del temp.txt


REM Display confirmation
msg %username% "File has now been sent to FTP"

goto :EOF

:error
msg "The file was uploaded or downloaded incorrectly"

太好了,谢谢你!我将在下面给出答案