SFTP in a script

Hi

I need to write a script which should make SFTP connection with one server.
Download some files and then exit.

Can we do this? I know this is possible with FTP but is it is possible with SFTP too?

Can you please provide some example?

Regards
Kapil

Using ssh keys all you need to do is something like:

scp login@server:/path/file/to/download /path/to/file/downloaded

(do not forget scp option -r for folders, or * for multilple files with a common pattern)

Use ssh keybased authentication to enable login with out password.

sftp server << 01
#commands to be executed for file transfer
get file
01

or like Cabrao said use scp. for both to work in script, you have to enabled keybased authentication.

How do you do this?