While executing the below code. the script gets hanged. /var/backups/archives/ contains about 3 files with around 5GB in size. It copies the first file and scripts hangs.
spawn scp -rp user@10.10.234.1:/var/backups/archives/ /var/backup
expect "user@10.10.234.1's password:"
send "password\n"
expect eof
if [catch wait] {
puts "failed"
exit 1
}
exit 0
I assume you'll see expect: timed out
when you run your script with expect -d
.
Insert set timeout 60
in a new line after send "password\n"
. Replace 60
with a number greater than the transfer time (in seconds) of all files.