Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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}
    cd $remoteDir
    ls ${fileSpec}*

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

    # 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 ;;

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


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.