我想,你必須把它包裝在一個shell腳本中。
的shell腳本必須生成一個腳本lftp的樣,比如:
set xfer:log true
set xfer:log-file "/path/to/somewhere/$DATESTAMP.log"
lcd "/path/of/source"
open -u $UN,$Pass sftp://$Server
mirror -R $Directory
quit
通過lftp -f $ScriptName
執行。
然後,解析生成的日誌文件; AFAIK它只包含成功的轉賬。
awk '{print $3,$6}' $DATESTAMP.log | sed -r -e 's/ [0-9]+-/ /'
以上將生成爲每個文件傳輸的文件和字節的列表。您可以通過循環的結果與實際的文件大小比較,例如
# WARNING: Script assumes that filename contains no space.
while read fname fsize; do
# The following line used if the lftp runs from e.g. the source folder
actualname=$Prefix/$fname
actualsize=$(stat -c "%s" "$actualname")
if ((actualsize != fsize)); then
# Some error handling code here
fi
done <<< "$(awk '{print $3,$6}' $DATESTAMP.log | sed -r -e 's/ [0-9]+-/ /')"
注:我用的是「herestring」存在,而不是管道,使的while
循環中的變量操縱。
有人嗎?任何想法?這種轉移仍然間歇性地失敗,沒有任何日誌。 –