在shell中恢复mget


0

我在主机B中有一大堆文件,我正在尝试从主机A的shell中获取这些文件(主机A允许shell访问,而主机B不提供ftp访问)。 在作业中间,连接丢失,主机B中只有一半的文件被转移到主机A.我正在尝试恢复mget而不覆盖主机A中已传输的文件,但无法弄清楚如何做它。伙计们好吗?

PS:mreget在主机A的shell中不可用

Answers:


0

一种更通用的方法是捕获关于B上的内容的信息,确认他们都得到A或继续重新输入,直到你得到它们。

就像是

until ${allFilesTransfered:-false} ; do
    # get in file list of remote Files
ftp -in  > ${mgetTargets} <<-EOS
    open ${RemoteHost}
    $passwd
    cd $remoteDir
    ls ${fileSpec}*
    quit
    EOS

    # transport files with mget
    ftp -in <<-EOS
    open ${RemoteHost}
    $passwd
    prompt
    binary
    cd $remoteDir
    lcd $localDir
    mget $( cat mgetTargets )
    quit
    EOS

    # make a tmp file with files that are
    # now on your local machine
    cd $localDir
    ls -l > ${localDirOutput)

    # compare the 2 lists with diff,
    # if not diffs, then all files were copied
    diffOut="$(diff - ${localDirOutput} ${mgetTargets})"
case "${diffOut:-no_outputFound}" in
   no_outputFound ) allFilesTransfered=true ;;
esac
done

其中mgetTargets和locaDirOutput将被定义为指向文件。

我没有足够的资源或时间来做到这一点,但希望你能得到这个想法。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.