Linux or unix FTP 上传下载实例

命令行方式使用FTP实战练习

简单上传下载实例(/*....*/为注释):

先假设有一FTP服务器,FTP服务器:qint.ithot.net,用户名:username   密码:user1234。在本地电脑D:盘创建一个文件夹"qint"。将要上传的文件复制到d:\qint里。通过FTP命令将文件从本地上传,从服务 器下载的步骤如下:

1.“开始”-“运行”-输入“FTP”

2.open qint.ithot.net
/*这一步可以与第一步合并,在“运行”里直接输入"ftp qint.ithot.net"。如果你的FTP服务器不是用的21默认端口,假如端口是2121,那么此步的命令应在后面空格加2121,即“open qint.ithot.net 2121”*/

3.username
/*提示你输入用户名*/

4.user1234
/*提示你输入密码,密码不回显,打完密码后回车即可。如果你的密码输入错误,将不会提示你重新输入,这时你要键入“user”命令,将会出现第三步,你可以重新输入用户名和密码。*/

5.dir
/*你成功登陆后就可以用dir查看命令查看FTP服务器中的文件及目录,用ls命令只可以查看文件。*/

6.mkdir qint
/*在FTP服务器上根目录下建立qint目录。*/

7.cd qint
/*进入目录qint,用“cd 你的目录名”可以进入当前目录的下一级目录,这跟DOS一样。*/

8.bin
/*采用二进制传输。如果你要上传下载,这一步很重要,不先执行这个命令,上传下载会很慢。*/

9.lcd d:\qint
/*定位本地默认文件夹,在前面我事先在D:盘创建的。*/

10.!dir
/*查看本地文件夹中的文件及目录*/

11.put i001.jpg
/*将当前目录(d:\qint)中的文件i001.jpg上传到FTP服务器默认目录。可以用"mput *.*"将所有文件上传到FTP服务器上。*/

12.get d123.jpg
/*将FTP服务器默认目录中的文件d123.jpg下载到当前目录下(d:\qint)。可以用"mget *.*"将所有文件下载到d:\qint*/,或者可以用“mget * ”将文件夹下的所有的目录里的文件下载到指定的文件夹中。(批下载文件,自动下载全部文件, prom 回车,然后用mget),Linux下通过ftp命令实现断点续传, 使用Linux下ftp命令,使用reget替代mget和get命令;(get前最好还用上bin和hash命令,表示二进制文件、显示传输进度); 注:没试验过sftp是否也支持断点续传

13.delete *.*
/*删除目录qint中的所有文件。*/

14.cd ..
/*返回至上一级目录,即根目录。返回上一级目录用“cd ..”要注意,中间有空格。返回根目录用“cd \”。*/

15.mrdir qint
/*删除目录qint。删除目录,在此目录下不能有文件及目录,不然将无法删除。*/

16.bye
/*退出FTP服务器*/

上传下载时特别要注意服务器及本地电脑的当前目录,文件是从哪里到哪里的问题。查看FTP服务器的当前目录命令为pwd,可以用cd命令定位服务器 的目录。可以用lcd命令定位本地电脑的目录。以上实例应用到了采用FTP命令行方式上传下载的最常用命令,你还可以用命令“?”查看更多的命令。

 

MGET Command

HSI Version:

All

Purpose:

Retrieves a copy of a file from HPSS to your local file space on the host system (same as GET command), with interactive prompt to confirm "get" of each file.

Aliases:  

Command Format:

mget[]  [-B | -b] [-C] [-h] [-L ofs path] [-N] [-o] [-O srcofs:sinkofs:length]
                    [-P | -p] [-R | -r] [-S]  [-t] [-U | -u] [path ...] [<<MARKER] 

Options:

-B | -b : backup option. Renames any existing local file by appending "~". (This option may not be used with -L,-t, or -O)

-C : cache purge option. If specified, purge files from HPSS disk cache after a successful get. Normally used only when it's expected that files will only be fetched once (or infrequently), to help optimize disk cache use.

-h : symlink option. If specified, create local symlink if HPSS symlink. If not set, reads through HPSS symlinks when copying files to local filesystem

-L : pathname of a file containing lists of partial file offsets, in the form specified by -O (see below). Multiple entries per line may be specified. -O option(s), if any, are processed before any -L entries

-N : disable auto-scheduling of retrievals. Default is to schedule retrievals in an optimal way so as to minimize HPSS tape mounts

-O : partial file transfer. "srcofs" is the source file offset, "sinkofs" is the sink file offset, "length" is the transfer length. Missing options use defaults (src: 0, sink: 0, length: entire file). "CP" or "0CP" (case-insensitve) can be used to specify "current position". Multiple -O options may be specified, and are processed in order. Offsets may specified with case-insensitive suffixes "k", "kb",etc.

-P | -p : preserve timestamp. Attempts to copy HPSS file's timestamp to local file.

-R | -r : recursively fetch directories

-S : disable staging of the source file (attempts to read directly from tape). Users having trouble retrieving files over 25 GB in size may wish to use the -S option for the get or mget commands. The -S option was added to allow users to disable staging files from tape, specifically for this type of situation.

-t : "re-get" option. Restart a previously failed operation. This is equivalent to "-O sizeof(localfile):sizeof(localfile):0". Note: -t may not be used with -O or -L

-U | -u : update option. Only copy file from HPSS if local file timestamp is older

MARKER : provides sh-style "here"-document syntax for specifying filenames. Lines following the MARKER, which must be the last token on the line, contain pathname (which may include wildcards). The list is terminated by a line containing MARKER as the first token on the line. If -O,-L is specified, offsets apply only to the first file transferred.

Keywords:

 

Usage Notes:

Interactive prompting can be toggled with the PROMPT command.

Example:

mget *

Related Command(s):

 

猜你喜欢

转载自sundful.iteye.com/blog/1727073