1

I have an expect script that I have written that at the end calls scp to copy a large file from server A to server B.

The issue I have (which is the same using rsync and not scp) is that the expect script is terminating before the file transfer is complete. I know that I can set the timeout in expect but as the file size grows so will the timeout.

Is there anyone that has come across this issue and is there a wait function that I can use in expect?

Many thanks.

splattne
  • 28,508
  • 20
  • 98
  • 148
aHunter
  • 314
  • 1
  • 6
  • 21

2 Answers2

4

According to http://oreilly.com/catalog/expect/chapter/ch03.html, you can simply set timeout to -1 to disable the timeout mechanism.

larsks
  • 43,623
  • 14
  • 121
  • 180
2

Two things, number one, yes, set timeout -1 if you do not want it to timeout.

Secondly, you should use wait to allow the scp or rsync command to complete. Simply waiting forever is not nearly as robust...

Last comment, I was an scp user for quite some time but have really grown to love the delta, partial and sparse abilites of rsync. With these, even if the transfer is disconnected, it can pick back up where it left off which is immensely helpful at times....especially if waiting forever anyway ;)

Something like:

rsync -a -v -i --timeout=30 --stats --log-file="$LOG_FILE" --partial --exclude 'log*.txt' "$DATA_DIR"/"$DATE" $DEST:"$DEST_DIR"

(This pushes from the node to the master)

Doing this can save some serious bandwidth when transferring large files, spotty networks, etc...

eulerworks
  • 161
  • 5