views:

1327

answers:

5

Command-line sftp in my Ubuntu doesn't have recursive put implemented. I found some debate from 2004 about implementing such feature with -R option switch. So I see some sort of self-made recursion as only option.

Ie.

  • iterate through directory listing
  • cd into directories
  • mkdir them if nonexistent
  • put files

I'm planning on doing this with bash, but any other language would suffice.

Rsync or scp is not an option because I don't have shell access to server. Only sftp.

A: 

I guess you can do this with bash but it's going to be a lot of work. Instead, I suggest to have a look at Python and the Chilkat library.

Aaron Digulla
A: 

In Java, you can use edtFTPj/PRO, our commercial product, to transfer recursively via SFTP. Alternatively you might want to consider SCP - that generally supports recursion and runs over SSH.

Bruce Blackshaw
A: 

How about sshfs?

Combined, of course, with cp -r.

Or, failing that, rsync -r by itself.

Ryan Thompson
Quote from the question: "Rsync or scp is not an option because I don't have shell access to server. Only sftp."Sshfs requires ssh access and I only have sftp.
aarreoskari
Huh. I've never heard of having sftp access without ssh access, so I guess my brain ignored that part. You could still try sshfs. I don't actually know whether it works by ssh or sftp. If you're using GNOME or KDE, you can just type sftp paths into their respective file browsers.
Ryan Thompson
A: 

After lot's of googling and good answers I used Transmit syncing for the job. Not a very good solution, but does the job.

aarreoskari
A: 

Look at lftp. It's a powerful file transfer client which supports ftp, ftps, http, https, hftp, fish (file transfer over ssh shell session) and sftp. It has ftp-like interactive interface, but also allows to specify all commands at the command line. Look at mput (non recursive but handles glob patterns) and mirror (poor man's rsync) commands.

I use it with a server which only handles sftp uploads like this:

lftp -c "open -u $MYUSER,$MYPASSWORD sftp://$TARGET ; mirror -R $SOME_DIRECTORY"
Ilia K.