Answers:
一种更通用的方法是捕获关于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将被定义为指向文件。
我没有足够的资源或时间来做到这一点,但希望你能得到这个想法。