确认用户的FTP上传

时间:2019-05-15 13:40:03

标签: batch-file cmd ftp

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

我很清楚,这样做时无法检查错误,但这不是我的目标。

我的代码可以按预期工作,但是我丢失了……某物

我需要让用户知道,在我将文件放入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"

任何帮助将不胜感激。如果需要,我将添加更多信息

2 个答案:

答案 0 :(得分:1)

您必须重新下载文件,以查看文件是否正确上传,然后执行Build when a change is pushed to BitBucket

要通过fc下载无人值守的文件,请查看robvanderwoude's ftp。不要忘记,在保存下载的文件时,其名称应与最初上传的文件名称不同。

然后只需像这样通过ftp命令比较您拥有的文件:

fc

答案 1 :(得分:1)

出于视觉目的,针对我的问题的答案:

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"