scp – 转移报告100%完成(并被转移),但文件大小不正确

我正在使用scp在两个linux系统之间传输文件 – 当传输完成时,从SCP屏幕的最终打印显示错误的文件大小:

vmtbackup.zip 100% 2613MB 17.5MB/s 02:29 . 

正如你在这里看到的,最终报告的大小是2613MB,转移已经完成。 但是文件的实际大小是2741MB

当我检查目标系统时,文件具有正确的大小(因此传输已成功完成)。

我使用SCP的输出作为脚本的一部分,并且当SCP中的大小=文件大小(因为100%同样不可靠)时,检查条件是完成脚本 – 它是期望脚本的一部分,看起来像这样:

 function Transfer { /usr/bin/expect <<EOD #transfers the vmtbackup.zip file from source system to target system spawn scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no /tmp/vmtbackup.zip $user@$ip:/tmp/ expect { #handles all unexpected outcomes. Primarily used to capture wrong password, as no remote connection should be caught earlier in migration.sh default { send_user "\nERROR: I was unable to connect to $ip for some reason. Please try again.\n" exit 1 } #passes the password defined in migration.sh to scp password prompt" -re "root@$ip's \[pP\]assword:" { send -- "$password\r" exp_continue } -re "\[pP\]assword:" { send -- "$password\r" exp_continue } -re "ETA" { exp_continue } #when file transfer reaches 100%, exits script -re "$si" { exit 0 } EOD } 

我知道明文使用密码的安全含义,我应该使用SSL,但现在这不是问题的一部分。

谁能告诉我SCP为什么会这样呢?

scp错误地显示MB ,这意味着该因子是1000 * 1000 。 它应该显示MiB ,这是因子1024 * 1024

 2613 MiB == 2613 * (1024 * 1024) / (1000 * 1000) == 2739.929088 MB 

有关详细信息,请参阅IEEE 1541-2002 。