Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

i have a large set of files in host B and i'm trying to mget these files from the shell of host A (host A allows shell access while host B doesnt but gives ftp access). In the middle of the job, the connection was lost and only half the number of files in host B were transferred to host A. I'm trying to resume mget without overwriting the already transferred files in host A but cant figure out how to do it. Any idea guys ?

PS: mreget is not available in host A's shell

share|improve this question

1 Answer 1

up vote 0 down vote accepted

A more generic approach would be to capture information about what is on B, confirm they all got to A or keep retying until you get them all.

something like

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

where mgetTargets and locaDirOutput would be defined to point to files.

I don't really have the resources or time to make this exact, but hopefully you get the idea.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.