macos 通过 Mac 终端上传文件夹
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1273569/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Upload Folder via Mac Terminal
提问by Zach Smith
How can I upload an entire folder via FTP Mac Terminal?
如何通过 FTP Mac 终端上传整个文件夹?
回答by dustmachine
Do you have to use ftp
? I like to use scp
(secure copy) when the remote host supports ssh (as so many of them do).
你必须使用ftp
吗?我喜欢scp
在远程主机支持 ssh 时使用(secure copy)(很多人都这样做)。
scp -r mydirectory [email protected]:destdir
scp -r mydirectory [email protected]:destdir
The -r
means "recursive" so it will recursively copy the entire directory. Replace username
with your username, etc., etc. destdir
is a relative path on the remote server (whatever directory you wind up in if you log in) as long as you don't use a leading slash /
-- then it will be an absolute path.
的-r
意思是“递归”,所以将递归复制整个目录。替换username
为您的用户名等,等等 destdir
是远程服务器上的相对路径(无论您登录后进入哪个目录),只要您不使用前导斜杠/
——那么它将是一个绝对路径.
回答by lexu
terminal>ftp user@host
password:xXxXx
ftp>mkdir <remote dir>
ftp>cd <remote dir>
ftp>lcd <local dir>
ftp>mput *
ftp>close
This will
这会
- connect
- create the remote directory (or folder)
- cd into that directory
- cd to the local directory (if you didn't start there
- copy multiple files (all)
- log out again
- 连接
- 创建远程目录(或文件夹)
- cd 进入那个目录
- cd 到本地目录(如果你没有从那里开始
- 复制多个文件(全部)
- 再次登出
回答by DEAD10CC
mput is the right command for that task, but I think OS X' implementation of ftp command line client does not support recursive copy of directories via mput *.
mput 是该任务的正确命令,但我认为 ftp 命令行客户端的 OS X 实现不支持通过 mput * 递归复制目录。
So, a possible solution might be the use of an alternative ftp command line client like NcFTP that is shipped with many linux distributions and is also available for OS X. See NcFTP download pagefor details.
因此,一个可能的解决方案可能是使用替代的 ftp 命令行客户端,如 NcFTP,它随许多 Linux 发行版一起提供,也可用于 OS X。有关详细信息,请参阅NcFTP 下载页面。
ncftpput -R -u user -p passwd <remote-host> <remote-dir> <local-dir>
The -R
is for recursive mode.
的-R
是递归模式。
回答by David Rodman
Go - Connect To Server. Enter ftp://ip-address-of-other-boxand appropriate credentials. Click + to add that server, then double-click on it to open it. You can now drag and drop folders and it will copy recursively.
去 - 连接到服务器。输入ftp://ip-address-of-other-box和适当的凭据。单击 + 添加该服务器,然后双击将其打开。您现在可以拖放文件夹,它将递归复制。
回答by David Rodman
Same as you would upload an entire folder from any other command line:
与从任何其他命令行上传整个文件夹相同:
- Make a zip or tar archive out of it, then put the archive.
- If you want to upload individual files, but do them all, use "mput".
- 用它制作一个 zip 或 tar 存档,然后放置存档。
- 如果您想上传单个文件,但要全部上传,请使用“mput”。
回答by ennuikiller
have you tried mput? You can pass it A wildcard (*) to upload all the files...
你试过mput吗?可以通过通配符(*)来上传所有文件...
回答by Charles Shoults
There seems to be some question as to whether ftp through the mac is capable of handling recursive copy.
If you have ssh access to both machines, you could do this from the source computer:
tar -cf - directory | ssh user@hostB "cd target_dir; tar -xf -"
关于通过 mac 的 ftp 是否能够处理递归复制,似乎存在一些问题。
如果您对两台机器都有 ssh 访问权限,您可以从源计算机执行此操作: tar -cf - directory | ssh user@hostB "cd target_dir; tar -xf -"
mput * should work fine for objects within the directory, but if you have subdirectories, it may have problems picking up the files.
mput * 对于目录中的对象应该可以正常工作,但是如果您有子目录,则获取文件可能会出现问题。