zoukankan      html  css  js  c++  java
  • Windows命令行使用FTP

    Windows命令行使用FTP

    1.系统环境

      FTP客户端:Windows7旗舰版,管理员权限命令行;

      FTP服务端:CentOS 6.5,VSFTP,端口 21(默认)

    2.登陆FTP

    1. 在命令行下输入 ftp,出现 ftp>即进入FTP命令行
    2. open FTP的IP地址/域名 例如 open 169.254.234.241 (当然有最简单的方式 直接在命令行下 ftp FTP的IP地址/域名
    3. 按照提示输入用户名和密码,完成登陆
    复制代码
    Microsoft Windows [版本 6.1.7601]
    版权所有 (c) 2009 Microsoft Corporation。保留所有权利。
    
    C:UsersAdministrator>ftp
    ftp> open 169.254.234.241
    连接到 169.254.234.241。
    220 Welcome to blah FTP service.
    用户(169.254.234.241:(none)): wy
    331 Please specify the password.
    密码:
    230 Login successful.
    ftp>
    复制代码

    3.上传一个文件

    1. put(或者 send,上传多个使用 mput) 文件名(包含路径) 例如 put C:UsersAdministratorDocumentsMyself.pub
    2. ls(或者 dir) 查看当前目录文件
    复制代码
    ftp> put C:UsersAdministratorDocumentsMyself.pub
    200 PORT command successful. Consider using PASV.
    150 Ok to send data.
    226 Transfer complete.
    ftp: 发送 233 字节,用时 0.02秒 14.56千字节/秒。
    ftp> send C:UsersAdministratorDocumentsMyself
    200 PORT command successful. Consider using PASV.
    150 Ok to send data.
    226 Transfer complete.
    ftp: 发送 1004 字节,用时 0.00秒 1004000.00千字节/秒
    ftp> ls
    200 PORT command successful. Consider using PASV.
    150 Here comes the directory listing.
    Myself
    Myself.pub
    226 Directory send OK.
    ftp: 收到 20 字节,用时 0.00秒 20.00千字节/秒。
    ftp>
    复制代码

      很显然,send 的速度比 put 快不少。但是他们两个的区别我没有详细的查。

    4.下载一个文件

    1. lcd 本地目录路径 设置当前工作路径,也就是你要把文件下载到哪。默认是在当前使用命令行的用户的主目录。我的是 C:UsersAdministrator。也可以使用 !chdir 查看当前目录。
    2. cd 服务器目录 进入到你要下载的文件在服务器端的目录位置
    3. get(下载多个用 mget) 文件名 下载该文件。例如 get Myself
    4. !dir 查看当前目录文件,就能看到你刚才下载的文件啦
    复制代码
    ftp> dir
    200 PORT command successful. Consider using PASV.
    150 Here comes the directory listing.
    -rw-r--r--    1 500      500           986 Dec 03 10:08 Myself
    -rw-r--r--    1 500      500           233 Dec 03 10:07 Myself.pub
    226 Directory send OK.
    ftp: 收到 132 字节,用时 0.00秒 132000.00千字节/秒。
    ftp> !cd C:UsersAdministratorDesktop
    ftp> !chdir
    C:UsersAdministrator
    ftp> lcd C:UsersAdministratorDesktop
    目前的本地目录 C:UsersAdministratorDesktop。
    ftp> !chdir
    C:UsersAdministratorDesktop
    ftp> get Myself
    200 PORT command successful. Consider using PASV.
    150 Opening ASCII mode data connection for Myself (986 bytes).
    226 Transfer complete.
    ftp: 收到 1004 字节,用时 0.00秒 1004.00千字节/秒。
    ftp> dir
    200 PORT command successful. Consider using PASV.
    150 Here comes the directory listing.
    -rw-r--r--    1 500      500           986 Dec 03 10:08 Myself
    -rw-r--r--    1 500      500           233 Dec 03 10:07 Myself.pub
    226 Directory send OK.
    ftp: 收到 132 字节,用时 0.00秒 132.00千字节/秒。
    ftp> !dir
     驱动器 C 中的卷没有标签。
     卷的序列号是 941F-307E
    
     C:UsersAdministratorDesktop 的目录
    
    2013/12/03  18:27    <DIR>          .
    2013/12/03  18:27    <DIR>          ..
    2013/11/17  13:23               932 Evernote.lnk
    2013/11/24  15:43             1,023 FlashFXP.lnk
    2013/11/21  08:53             2,176 Git Shell.lnk
    2013/11/21  08:53               308 GitHub.appref-ms
    2013/12/03  18:27             1,004 Myself
    2013/10/26  21:26             1,627 SecureCRT.lnk
                   6 个文件          7,070 字节
                   2 个目录 50,591,227,904 可用字节
    ftp>
    复制代码

    5.断开连接

      bye 就是这样。

    复制代码
    ftp> status
    连接到 169.254.234.241。
    类型: ascii;详细: 开 ;铃声: 关 ;提示: 开 ;通配: 开
    调试: 关 ;哈希标记打印: 关 。
    ftp> bye
    221 Goodbye.
    
    C:UsersAdministrator>
    复制代码

    6.总结

      这里就是拿一个例子来说明了一下简单的上传和下载命令的使用。使用 help 和 help [Command] 来查看对应命令的解释。最后给出常用命令的说明和格式。

    命令 说明 格式 参数说明
    bye 结束与远程计算机的 FTP 会话并退出 ftp bye  
    cd 更改远程计算机上的工作目录 cd RemoteDirectory
    RemoteDirectory
    指定要更改的远程计算机上的目录。
    dir 显示远程计算机上的目录文件和子目录列表 dir [RemoteDirectory] [LocalFile]
    RemoteDirectory
    指定要查看其列表的目录。如果没有指定目录,将使用远程计算机中的当前工作目录。
    LocalFile
    指定要存储列表的本地文件。如果没有指定本地文件,则屏幕上将显示结果。
     
    get

    使用当前文件传输类型将远程文件复制到本地计算机。如果没有指定 LocalFile,文件就会赋以 RemoteFile 名。get 命令与 recv 相同。

    get RemoteFile [LocalFile]
    RemoteFile
    指定要复制的远程文件。
    LocalFile
    指定要在本地计算机上使用的文件名。
    lcd 更改本地计算机上的工作目录。默认情况下,工作目录是启动 ftp 的目录 lcd [Directory]
    Directory
    指定要更改的本地计算机上的目录。如果没有指定 Directory,将显示本地计算机中的当前工作目录。
    ls 显示远程目录上的文件和子目录的简短列表 ls [RemoteDirectory] [LocalFile]  
    RemoteDirectory
    指定要查看其列表的目录。如果没有指定目录,将使用远程计算机中的当前工作目录。
    LocalFile
    指定要存储列表的本地文件。如果没有指定本地文件,将在屏幕上显示结果。
    open 与指定的 FTP 服务器连接。可以使用 IP 地址或计算机名(两种情况下都必须使用 DNS 服务器或主机文件)指定 Computer。 open Computer [Port]
    Computer
    必需。指定试图要连接的远程计算机。
    Port
    指定用于联系 FTP 服务器的 TCP 端口号。默认情况下,使用 TCP 端口号 21。
    put(send)

    使用当前文件传输类型将本地文件复制到远程计算机上。put 命令与 send 命令相同。如果没有指定 RemoteFile,文件就会赋以 LocalFile 名。 

    put LocalFile [RemoteFile]
    LocalFile
    指定要复制的本地文件。
    RemoteFile
    指定要在远程计算机上使用的名称。

    更多详细的说明请看http://technet.microsoft.com/zh-cn/library/cc756013(v=ws.10).aspx 和 http://blog.csdn.net/chaoqunz/article/details/5973317

  • 相关阅读:
    C Language Study
    html学习笔记五
    [CS]C#操作word
    bzoj2502 清理雪道
    Android Studio怎样查看资源或者函数在哪些类中被引用
    jvm载入过程
    poj2513(无向图判欧拉路)
    7 天玩转 ASP.NET MVC — 第 2 天
    从头认识java-18.2 主要的线程机制(7)join
    启动MFC程序的时候报错:0xC0000005: 读取位置 0x00000000 时发生访问冲突
  • 原文地址:https://www.cnblogs.com/gered/p/11118834.html
Copyright © 2011-2022 走看看