-1

我有一个调用 scp 将大文件从服务器 a 复制到服务器 b 的期望脚本。目前作为一种解决方法,我只使用“设置超时-1”。谢谢

4

1 回答 1

2

If the transfer is going to take a long (and unpredictable amount of) time, it's reasonable to turn off the timeout. However, it might be better to write your code so that it detects the progress updates that scp prints and then continues to wait:

expect {
    "ETA" {
        puts "still transferring..."
        exp_continue;        # <<<<--- magical
    }
    "100%" {
        puts "done"
    }
}

Like this, you timeout if there's been no updates at all for a while, whereas any update causes the printing of a message (which you probably ought to customize) and to wait for the next update (up to the overall timeout).

于 2013-06-20T08:27:42.807 回答