Web Hosting Talk







View Full Version : sftp script


syskarthik
08-08-2005, 10:26 AM
Hi all,

I am trying to have shell script - having need to download some files from a remote server. The only access to the remote server we have is sftp.

The script needs to dynamically get the new files from the server and get download.

Code i am trying to use :
----------------------------------------
sftp -b batchfile test@x.x.x.x

where in batchfile :

ls > somefile
get *.*
-----------------------------------------

here the line : "ls > somefile " doesn't seem to work putting list of files to "somefile" - giving the error :

Couldn't stat remote file: No such file or directory

Please advise the same thing can be done in any other possible way.

Thanks in advance,
karthik.k

tamasrepus
08-08-2005, 04:43 PM
Consider rsync over SSH. You would still need to setup public key authentication and what not to avoid passwords (same as you would have to do with sftp), but the command to sync a local directory to a remote one would be something like:

rsync -e ssh -a --partial test@x.x.x.x/somepath/ ./localdirectory/