sftp put command

By mrlayance ·
I am trying to get the put command with sftp to upload a whole folder/directory with files within.

Does anyone know how to achieve this?

This conversation is currently closed to new comments.

3 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Collapse -

sftp may not create directory structure, but scp can...

by rmerchberger In reply to sftp put command

sftp can up/download multiple files (and you can use wildcards) with mput / mget, but I don't think it recreates directory structure.

Most sftp servers will also speak scp (Secure Copy - still uses the SSH daemon) and if you issue this command:

scp -r localdir remoteuser@remotehost:/remotedir

{ and if your remote server uses a different port - some are setup for 1922 or 10022 for example, you'll have to add the -P [port] flag before the -r } that should do what you need.

If your server doesn't support scp and the filenames of the files don't change much either, you might be able to create a batch file of all the commands necessary to recreate the directory structure and use the -b flag for sftp. From the man page:

-b batchfile
Batch mode reads a series of commands from an input batchfile instead of stdin. Since it lacks user interaction it should be used in conjunction with non-interactive authentication. A batchfile of '-' may be used to indicate standard input. sftp will abort if any of the following commands fail: get, put, rename, ln, rm, mkdir, chdir, ls, lchdir, chmod, chown, chgrp, lpwd and lmkdir. Termination on error can be suppressed on a command by command basis by prefixing the command with a '-' character (for example, -rm /tmp/blah*).

Hope this helps,

Collapse -


by oldbaritone In reply to sftp put command

check mput/mget command.

Back to Software Forum
3 total posts (Page 1 of 1)  

Related Discussions

Related Forums