SFTP to transfer files from one server to another

Hello,

i have to write a script to perform sftp from the remote server to another server.
the files which are at the remote location are huge data log files which should be transfered to my server in a particular folder.

could you please provide me the general code (simple ) so that i can atleast start that script.

Thanks

IF I get what you are doing:

  1. run code on server A
  2. copy files from server B to server C

scp will let you do this easily

sftp me@serverb <<EOF > filelist
ls /path/to/*
exut
EOF
while read bigfile
do
   var=`basename $bigfile`
   scp me@serverb:$bigfile  me@serverc:/path/to/somewhere/else/$var
done < filelist

You will have to install ssh keys to run this command in batch -- if they don't already exist:

ssh-keygen: password-less SSH login

step by step howto.