The mget
subcommand in sftp is an alias to get
:
static const struct CMD cmds[] = {
{ "bye", I_QUIT, NOARGS },
...
{ "get", I_GET, REMOTE },
{ "mget", I_GET, REMOTE },
...
};
The get
subcommand has a syntax of:
get [-afPpr] remote-path [local-path]
If you give get
or mget
multiple parameters, it treats the second one as the rename destination for the first. As a result, you cannot retrieve multiple directories at once; you'll need to get them separately:
mget -r folder1
mget -r folder2
The sftp syntax also does not allow for shell-style command chaining, so you cannot use a command like: get -r folder1 && ...
. There is also no need to try and sleep
between get commands, unless you need a delay for other purposes (a watching process locally, to spare the network for a few seconds, etc).
As an alternative to sftp
, consider scp
:
scp -r user@host:folder1 user@host:folder2 /local/directory
... which will recursively copy the remote folder1
and folder2
directories into the local /local/directory
.
scp
that I just added to my answer as another possibility. – Jeff Schaller Oct 30 '18 at 12:58