I'd use 'scp' instead of 'sftp':
Main Topics
Browse All TopicsI am working with Solaris 10 x86 on an HP DL360. I am trying to write a simple script to use sftp to download a directory tree.
The files I am trying to get are buried under 5 or so directory layers.
For example:
/test/dir1/path/to/the/fil
/test/dir2/path/to/the/fil
/test/dir3/path/to/the/fil
In the above example, I just want to connect to their SFTP server and download the 'test' directory, which would contain all the subdirs and files. I had this working on windows using putty, but it seems that unix cannot handle this task.
It looked like the perl module Net::SFTP could handle this, but I have been trying without success to install it for the past two days.
What is the best way to do this?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
RBEIMS:
For some reason, every time I try to use scp -r instead of SFTP I get the error:
unknown user 70273
I find this is odd because I am using the same username/password/key as when I successfully authenticate with the server using SFTP. I am wondering if I am being restricted on the server side to only use SFTP. Is it at all possible to use sftp with a script to do this?
I noticed now that SFTP doesn't need a shell in the other side to properly connect. Probably the server is not configured to give you a shell, so your scp fails and sftp doesn't.
You can call sftp with a bacth file:
sftp -b batch_file
Your batch file should contain something like:
chdir /test
get *
But I did not have a chance to test this. Please test it and let me know!
Apparently the sftp client doesn't support recursive copy. In this link they suggest to use scp to do recursive copies.
http://www.cae.wisc.edu/li
As you can't do this, I think that you only have one option:
To ask the system administrator to give you a shell so that you can use scp to copy the files. There are restricted shells that allow only the copies of files, maybe you could suggest that if they are too concerned about security.
http://dragontoe.org/rssh/
is ftp an option for you? If yes then you can use tools like wget with recursive dir copy
on windows you can do from command line. please see
http://www.experts-exchang
Have a look at rsync e.g.
Push:
/opt/rsync/bin/rsync -optlg --rsh=/usr/bin/ssh --rsync-path='/opt/rsync/b
Pull:
/opt/rsync/bin/rsync -optlg --rsh=/usr/bin/ssh --rsync-path='/opt/rsync/b
Business Accounts
Answer for Membership
by: RBEIMSPosted on 2009-08-19 at 11:54:27ID: 25135975
You could try to use
scp -r user@machine:/test your_local_dir
This will recursively copy the "/test" directory to "your_local_dir"