Guys,
I have a Linux Server (Debian 2.6.18-6-686)from which I want to sftp files to an external (unknown other than some form of windows)server.
If I issue the commands interactively, I get something like this (copied from the screen directly and anonomized):
DEBIAN:/usr/autoftp/scripts# sftp
UserName@www.xxx.yyy.zzz
Connecting to
www.xxx.yyy.zzz...
UserName@www.xxx.yyy.zzz's password:
sftp> cd IN
sftp> lcd /usr/autoftp/xfr
sftp> put *
Uploading test.csv to /HOME/IN/test.csv
test.csv 100% 726KB 5.4KB/s 02:15
sftp> quit
DEBIAN:/usr/autoftp/scripts#
and the file transfers properly.
However, if I run an expect script that looks like this:
#!/usr/bin/expect
spawn sftp
UserName@www.xxx.yyy.zzz
expect "password:"
sleep 2
send "password\r"
expect "sftp>"
send "cd IN\r"
expect "sftp>"
send "lcd /usr/autoftp/xfr\r"
expect "sftp>"
send "put *\r"
expect "sftp>"
send "exit\r"
I get the file transferring to about 60-70% then failing, with no error message. I tried running the sftp with the "-v" switch, but got no information about why the transfer failed. I looked in all the obvious places in /var/log and got nothing. This us utterly reproducible, but I've failed to find the reason...any clues?
And I just noticed the interactive work ends in "quit" while the script ends in "exit" but I don't *think* that will make a material difference, because the error is happening upstream of the difference.
(And yes, I know embedding passwords in a file is not clever, but humour me, I just want to get a script that runs so I can cron it....)
Thanks for any suggestions