【问题标题】:Confirmation of FTP upload for user确认用户的 FTP 上传
【发布时间】:2019-05-15 13:40:03
【问题描述】:

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

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

我的代码按预期工作,但我缺少...一些东西

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

非常感谢任何帮助。如果需要,我会添加更多信息

【问题讨论】:

    标签: batch-file cmd ftp


    【解决方案1】:

    您必须重新下载文件以查看它是否正确上传并执行fc

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

    然后通过fc 命令简单地比较您拥有的文件,如下所示:

    @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"
    

    【讨论】:

    • 太好了,谢谢!我将在下面显示答案
    【解决方案2】:

    出于视觉目的,具体回答我的问题:

    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"
    

    【讨论】:

      猜你喜欢
      • 2016-09-09
      • 1970-01-01
      • 1970-01-01
      • 2012-10-24
      • 1970-01-01
      • 1970-01-01
      • 2018-06-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多