It all works fine until I run the mget command. For some reason it only gets the first file, and then part of the second. I'm not sure why this happens and haven't found much on my own in the Expect Man Page. http://www.tcl.tk/man/expect5.31/expect.1.html.
Here's my expect script thus far:
Code: Select all
#!/usr/bin/expect
spawn sftp user@someserver.com
expect "Password:"
send "Some_Pass\n";
expect "sftp>"
send "cd fromcheetah\n"
expect "sftp>"
send "mget *\n"
expect "sftp>"
send "exit"
Any suggestions on how I can make sure that I get ALL the files before expect exits?
UPDATE:
Finally found the solution. In passing the Expect Man Page says that the default timeout for "expect" is 10 seconds. I just had to set that to a longer time so that it would wait for the file transfer to finish. The correct script is below:
Code: Select all
#!/usr/bin/expect
spawn sftp user@someserver.com
expect "Password:"
send "Some_Pass\n";
expect "sftp>"
send "cd fromcheetah\n"
expect "sftp>"
send "mget *\n"
set timeout 10000
expect "sftp>"
send "exit"