FTP命令将目录从本地系统放入服务器

时间:2011-05-11 21:18:29

标签: linux shell unix ftp

put  filename  will put the file to cureent directory in server.

我必须使用哪个命令来移动整个文件夹/目录?

4 个答案:

答案 0 :(得分:5)

mput *

ftp无法直接放置目录树,只能放置文件。

答案 1 :(得分:4)

您可以使用ncftp软件将目录树从本地服务器放到ftp服务器上。 您需要安装此ftp软件。

上传命令将是:

ncftpput -avR -u <user> -p<password> <ftpserver> <path to put> <local folder>

其中,

a以ASCII模式传输所有文件,而不是二进制文件。

v以详细模式查看输出

R以递归模式复制文件夹。

答案 2 :(得分:1)

如果您在远程系统上有sshd,则可以使用rsync

它具有内置压缩和各种其他优点:

% rsync -chavz --partial --progress --stats test remotehost:
sending incremental file list
test/
test/test.c
         387 100%    0.00kB/s    0:00:00 (xfer#1, to-check=5/7)
test/test.cpp
         231 100%  225.59kB/s    0:00:00 (xfer#2, to-check=4/7)
test/test.new
         253 100%  123.54kB/s    0:00:00 (xfer#3, to-check=3/7)
test/test.php
         578 100%  282.23kB/s    0:00:00 (xfer#4, to-check=2/7)
test/test.py
         288 100%  140.62kB/s    0:00:00 (xfer#5, to-check=1/7)
test/test.sh
          81 100%   26.37kB/s    0:00:00 (xfer#6, to-check=0/7)

Number of files: 7
Number of files transferred: 6
Total file size: 1.82K bytes
Total transferred file size: 1.82K bytes
Literal data: 1.82K bytes
Matched data: 0 bytes
File list size: 193
File list generation time: 0.003 seconds
File list transfer time: 0.000 seconds
Total bytes sent: 1.54K
Total bytes received: 130

sent 1.54K bytes  received 130 bytes  159.43 bytes/sec
total size is 1.82K  speedup is 1.09

观察如果再次运行并且没有文件发生变化会发生什么......

% rsync -chavz --partial --progress --stats test remotehost:
sending incremental file list

Number of files: 7
Number of files transferred: 0
Total file size: 1.82K bytes
Total transferred file size: 0 bytes
Literal data: 0 bytes
Matched data: 0 bytes
File list size: 193
File list generation time: 0.003 seconds
File list transfer time: 0.000 seconds
Total bytes sent: 207
Total bytes received: 13

sent 207 bytes  received 13 bytes  23.16 bytes/sec
total size is 1.82K  speedup is 8.26

答案 3 :(得分:0)

没办法。您必须单独上传每个文件。您可以先抓取目录然后上传每个文件。你有这个限制通过ftp删除一个目录。