FTP命令详解(含操作实例)

上一篇 / 下一篇  2017-02-22 14:36:26

操作实例环境:

主机(FTP客户端):192.168.65.1  window 7  64bit

远程FTP服务器:192.168.65.131   redhat 5   vsftp

 

账号:dylan

密码:dylan

 

命令行选项

1.1 选项介绍

我们在命令行用以下选项使用FTP
ftp [-v] [-d] [-i] [-n] [-g] [-s:filename] [-a] [-w:windowsize] [computer]

· -v -  禁止显示远程服务器相应信息

· -n -  禁止自动登录

· -i -   多文件传输过程中关闭交互提示

· -d -  启用调试,显示所有客户端与服务器端传递的命令

· -g -  禁用文件名通配符,允许在本地文件和路径名中使用

· -s:filename - 指定包含 FTP 命令的文本文件;命令在FTP启动后自动运行。此参数中没有空格。可替代重定向符(>)使用。

· -a -  在绑字数据连接时使用所有本地接口

· -w:windowsize - 覆盖默认的传输缓冲区大小 65535

· computer -  指定远程电脑计算机名或IP地址。此参数必须放到最后。

1.2 操作实例

-v -  禁止显示远程服务器相应信息

使用前:

C:\Users\Administrator>ftp 192.168.65.131

连接到 192.168.65.131

220 **************Welcome to blah vsFTP service.**************

用户(192.168.65.131:(none)): dylan

331 Please specify the password.

密码:

230 Login successful.

ftp> status

连接到 192.168.65.131

类型: ascii;详细开 ;铃声关 ;提示开 ;通配

调试关 ;哈希标记打印关 。

ftp> dir

200 PORT command successful. Consider using PASV.

150 Here comes the directory listing.

drwxrwxr-x    2 502      504          4096 Dec 07 15:36 ftp

-rw-rw-r--    1 502      504             0 Dec 07 15:35 hello.txt

226 Directory send OK.

ftp: 收到 128 字节,用时 0.00秒 128.00千字节/秒。

使用后:

C:\Users\Administrator>ftp -v 192.168.65.131

用户(192.168.65.131:(none)): dylan

密码:

ftp> dir

drwxrwxr-x    2 502      504          4096 Dec 07 15:36 ftp

-rw-rw-r--    1 502      504             0 Dec 07 15:35 hello.txt

 

-n -  禁止自动登录

C:\Users\Administrator>ftp -n 192.168.65.131

连接到 192.168.65.131

220 **************Welcome to blah vsFTP service.**************

C:\Users\Administrator>ftp -nv 192.168.65.131

ftp> user dylan dylan

ftp> dir

drwxrwxr-x    2 502      504          4096 Dec 07 15:36 ftp

-rw-rw-r--    1 502      504             0 Dec 07 15:35 hello.txt

 

-i -   多文件传输过程中关闭交互提示

使用前

 

ftp> mget *.txt

mget hello.txt? n

 

使用后

ftp> mget *.txt

 

注意:单文件传输不影响

 

-d -  启用调试,显示所有客户端与服务器端传递的命令

C:\Users\Administrator>ftp -nvd 192.168.65.131

ftp> user dylan dylan

---> USER dylan

---> PASS dylan

ftp> dir

---> PORT 192,168,65,1,236,113

---> LIST

drwxrwxr-x    2 502      504          4096 Dec 07 15:36 ftp

-rw-rw-r--    1 502      504             0 Dec 07 15:35 hello.txt

 

-g -  禁用文件名通配符,允许在本地文件和路径名中使用

ftp> dir he*.txt

-rw-rw-r--    1 502      504             0 Dec 07 15:35 hello.txt

ftp> mget hell*.txt

mget hell*.txt? y

Failed to open file.

ftp> get hell*.txt

Failed to open file.

 

-s:filename - 指定包含 FTP 命令的文本文件;命令在FTP启动后自动运行。此参数中没有空格。可替代重定向符(<)使用。

编写包含FTP命令的文件:dir.ftp

open 192.168.65.131

user dylan dylan

dir

 

调用:

C:\Users\Administrator>ftp -ivns:e:\ftp\dir.ftp

ftp> open 192.168.65.131

ftp> user dylan dylan

ftp> dir

drwxrwxr-x    2 502      504          4096 Dec 07 15:36 ftp

-rw-rw-r--    1 502      504             0 Dec 07 15:35 hello.txt

 

说明:其他几个不常用的先不做介绍以后有机会再补上。

 

客户端命令

2.1 命令概览

· ! -    执行本地命令

· ? -    显示FTP命令的说明

· append -   向远程服务器追加本地文件

· ascii -   设置文件传输类型为ASCII,默认类型

· bell -    每一个传输命令完成触发一次响铃(默认关闭)

· binary -   设置文件传输类型为binary(二进制传输) 

· bye -     结束FTP会话并退出

· cd -   改变远程工作目录

· close -   结束FTP会话并返回命令行

· debug -   开关调试(默认关闭)

· delete -   删除远程单个文件

· dir -   显示远程目录文件盒子目录列表

· disconnect -  从远程断开,重新获得FTP提示框

· get -   复制单个远程文件到本地

· glob -      开关文件名通配符(默认ON

· hash - Toggles hash-sign (#) printing for each data block transferred (default = OFF) 为每个缓冲区传输切换打印“#”(哈希标记打印)

· help -  显示FTP命令帮助信息(用法通”?“)

· lcd -   改变本地工作目录

· literal - Sends arguments, verbatim, to the remote FTP server 向远程FTP服务器逐字发送参数(发送任意 ftp 命令)

· ls -  显示远程目录文件和子目录的简短列表(只有文件名和目录名)

· mdelete -   删除远程一个或多个文件

· mdir -   列出多个远程目录的内容

· mget -  复制一个或多个远程文件至本地

· mkdir -  创建一个远程目录

· mls -  列出多个远程目录的内容

· mput -  复制一个或多个本地文件到远程

· open -  连接到指定的FTP服务器

· prompt -  开关交互提示(默认为ON

· put -  复制一个本地文件到远程

· pwd -   显示远程当前工作目录(字面意思:打印工作目录)

· quit -   结束FTP会话并退出FTP(功能通bye

· quote - Sends arguments, verbatim, to the remote FTP server (same as "literal") 发送任意 ftp 命令??

· recv -  复制远程文件到本地

· remotehelp - 显示远程命令帮助

· rename -   重命名远程文件

· rmdir -  删除远程目录

· send -   复制一个本地文件到远程(功能通put

· status -  显示当前FTP连接状态

· trace -  开关数据包追踪(默认为OFF

· type -  设置文件传输类型(默认为ASCII

· user -  发送新用户信息

· verbose -    开关详细模式

 

 

 

 

 

2.2 操作实例

! -    执行本地命令

ftp> !dir

 驱动器 中的卷是 文档

 卷的序列号是 0003-E430

 

 E:\ftp 的目录

 

2015/06/06  11:44    <DIR>          .

2015/06/06  11:44    <DIR>          ..

2015/06/06  09:23                42 dir.ftp

2015/06/06  11:44                10 localhello.txt

               2 个文件             52 字节

               2 个目录 51,202,547,712 可用字节

? -    显示FTP命令的说明

 

append -  向远程服务器追加本地文件

语法:Syntax: append local-file [remote-file]

注意:如果remote-file 未指定默认与local-file一致

 

[dylan@Redhat ~]$ cat hello.txt

ftp> append localhello.txt hello.txt

[dylan@Redhat ~]$ cat hello.txt

hello ftp.

ftp> append hello.txt

[dylan@Redhat ~]$ cat hello.txt

hello ftp.hello there!!!

ascii -   设置文件传输类型为ASCII,默认类型

ftp> ascii

200 Switching to ASCII mode.

 

binary -   设置文件传输类型为binary(二进制传输) 

ftp> binary

200 Switching to Binary mode.

bye -     结束FTP会话并退出

ftp> bye

 

C:\Users\Administrator>

cd -   改变远程工作目录

ftp> cd ftp

ftp> dir

-rw-rw-r--    1 502      504             0 Dec 07 15:36 ftp.txt

 

close -   结束FTP会话并返回命令行

ftp> close

ftp> dir

未连接。

ftp> open 192.168.65.131

ftp> user dylan

密码:

debug -  开关调试(默认关闭)

ftp> debug

调试 开 。

ftp> dir

---> TYPE A

---> PORT 192,168,65,1,252,103

---> LIST

-rw-rw-r--    1 502      504             0 Dec 07 15:36 ftp.txt

---> TYPE I

delete -   删除远程单个文件

ftp> del ftp.txt

---> DELE ftp.txt

dir -  显示远程目录文件盒子目录列表

ftp> dir

drwxrwxr-x    2 502      504          4096 Dec 07 19:22 ftp

-rw-rw-r--    1 502      504            24 Dec 07 19:00 hello.txt

disconnect -  从远程断开,重新获得FTP提示框

ftp> disconn

ftp> dir

未连接。

ftp> open 192.168.65.131

ftp> user dylan

密码:

get -   复制单个远程文件到本地

ftp> get hello.txt

ftp> !dir

 

2015/06/06  12:31                24 hello.txt

 

glob - 开关文件名通配符(默认ON

ftp> glob

通配 关 。

ftp> mget *.txt

Failed to open file.

help - 显示FTP命令帮助信息(用法通”?“)

ftp> help dir

dir             列出远程目录的内容

lcd -  改变本地工作目录

ftp> lcd e:\ftp

目前的本地目录 E:\ftp

ls - 显示远程目录文件和子目录的简短列表(只有文件名和目录名)

ftp> ls

ftp

hello.txt

mdelete -  删除远程一个或多个文件

ftp> ls

1.tmp

2.tmp

3.tmp

ftp

Hello.txt

ftp> mdel *.tmp

ftp> ls

ftp

hello.txt

mdir -  列出多个远程目录的内容

ftp> mdir - ftp -

drwxrwxr-x    2 502      504          4096 Dec 07 19:47 ftp

-rw-rw-r--    1 502      504            24 Dec 07 19:00 hello.txt

drwxr-xr-x    2 502      504          4096 Dec 07 19:31 tmp

-rw-rw-r--    1 502      504             0 Dec 07 19:47 1.tmp

-rw-rw-r--    1 502      504             0 Dec 07 19:47 2.tmp

-rw-rw-r--    1 502      504             0 Dec 07 19:47 3.tmp

mget -  复制一个或多个远程文件至本地

ftp> mget 1.tmp 2.tmp 3.tmp

mkdir - 创建一个远程目录

ftp> mkdir tmp

ftp> dir

drwxrwxr-x    2 502      504          4096 Dec 07 19:22 ftp

-rw-rw-r--    1 502      504            24 Dec 07 19:00 hello.txt

drwxr-xr-x    2 502      504          4096 Dec 07 19:31 tmp

· 

mls - 列出多个远程目录的内容

Syntax: mls remote-files [ ...] local-file

 

ftp> mls ftp -

ftp/1.tmp

ftp/2.tmp

ftp/3.tmp

mput -  复制一个或多个本地文件到远程

ftp> mput *.tmp

ftp> ls

1.tmp

2.tmp

3.tmp

 

open -  连接

TAG:

 

评分:0

我来说两句

日历

« 2024-04-25  
 123456
78910111213
14151617181920
21222324252627
282930    

数据统计

  • 访问量: 343373
  • 日志数: 46
  • 图片数: 2
  • 文件数: 4
  • 书签数: 1
  • 建立时间: 2012-08-01
  • 更新时间: 2019-02-20

RSS订阅

Open Toolbar