shell script to get sftp files

did anyone knows a script to get a latest file in a folder,,i try to get the newest file at a folder via sftp and i want to make a crontab to do this once a day,,can someone give me the script to get the latest file??

I'm willing to *help* you write it. but it's in the wrong section. I believe we have a section for shell scripting.

Hints:
You'll have to use an expect statement or a passwordless login (danger)
You'll have to play with commands in psftp to see what sort of things are possible with it to grab the newest files
You'll have to be willing to learn if you don't already know how to do something.

moved to the scripting section.

What do you have so far?

actually i`ve done it by 80%,,i already succeed in get the latest file via sftp with my script,,but when i cron it,it`s not succeed.And when i cron to get "a file"(hardcode it) via sftp it works like a charm,,i don`t undestand why when i get the latest file via sftp with cron it doestn work,,any suggestion?

Could you post the script? Could be a simple typo or not fully file path.