spawn sftp x...@test.com
expect "Password: "
send "test\r"
expect "sftp>"
send "ls\r"
expect "sftp>"
thanks in advance!
The pertinent Internet-Draft exposes
atime
mtime
createtime
ctime
for SFTP. Is mtime the one you have in mind for "latest file"?
Something along the following lines works for me, but I'm not that
familiar with driving sftp from expect, so there may be a better way:
...
expect "sftp>"
send "ls -tr1\r"
expect "sftp>"
set file [lindex [split $expect_out(buffer) \n] end-1]
puts "last file = $file"
Cheers,
Neil
Thanks for all the help. i want to automate download via sftp. please
suggest me better way if way's.
When driving sftp, expect is probably the way to go. Personally, I'd
wrap the send/expect sequences up in procedures so that I could write a
higher-level script like this:
proc getLastFile {} {
send "ls -tr1\r"
expect "sftp>"
return [lindex [split $expect_out(buffer) \n] end-1]
}
...
expect "sftp>"
set file [getLastFile]
puts "last file = $file"
Note that this is untested and might need some [global]s in there.
Season to taste. :-)
Donal.
good start for me thanks :)