I'm trying to automate data transfer using sftp.
I have a hacky expect script that grabs the data file. Unfortunately, partway through transfer the file is unexpectedly truncated. When I tried doing the same command by hand it always transfers the whole file.
The first line of my expect script is:
spawn sftp -o ConnectTimeout=120 username@boxAddress
I was under the impression that putting "-o ConnectTimeout=120" would prevent the connection from timing out if it stalled for less than two minutes.
What should I do to get the script to download the whole file?
Another, much less important question: I would prefer to authenticate using keys (but this isn't essential as I'm only grabbing data from the external server). I don't think I could put a key on this external server (because it is not under my control), but (when I used FileZilla to connect to it) I noticed that FileZilla accepted a key from it. How could I setup my script to ask for and use this key?