windows ftp 使用

來源:互聯網
上載者:User

1.下載地址:http://mina.apache.org/ftpserver-project/download_1.0.6.html

2.解壓到d:/ftp

3.修改d:/ftp/res/conf/ftpd-typical.xml 預設連接埠是2121 ,設定密碼為不加密


4.修改d:/ftp/res/conf/users.properties


5.啟動 ftpd.bat d:/ftp/res/conf/ftpd-typical.xml

6.輸入ftp://localhost:2121/ 測試,檔案存放位置D:\ftp\res\home

7.java測試(發現一些電腦出現異常,請關閉防火牆)

package test;import java.io.File;    import java.io.FileInputStream;    import org.apache.commons.net.ftp.FTPClient;    import org.apache.commons.net.ftp.FTPReply;        public class FTPtest {                 private  FTPClient ftp;          /**       *        * @param path 上傳到ftp伺服器哪個路徑下          * @param addr 地址       * @param port 連接埠號碼       * @param username 使用者名稱       * @param password 密碼       * @return       * @throws Exception       */        private  boolean connect(String path,String addr,int port,String username,String password) throws Exception {              boolean result = false;              ftp = new FTPClient();              int reply;              ftp.connect(addr,port);              ftp.login(username,password);              ftp.setFileType(FTPClient.BINARY_FILE_TYPE);              reply = ftp.getReplyCode();              if (!FTPReply.isPositiveCompletion(reply)) {                  ftp.disconnect();                  return result;              }              ftp.changeWorkingDirectory(path);              result = true;              return result;          }          /**       *        * @param file 上傳的檔案或檔案夾       * @throws Exception       */        private void upload(File file) throws Exception{              if(file.isDirectory()){                       ftp.makeDirectory(file.getName());                            ftp.changeWorkingDirectory(file.getName());                  String[] files = file.list();                         for (int i = 0; i < files.length; i++) {                      File file1 = new File(file.getPath()+"\\"+files[i] );                      if(file1.isDirectory()){                          upload(file1);                          ftp.changeToParentDirectory();                      }else{                                        File file2 = new File(file.getPath()+"\\"+files[i]);                          FileInputStream input = new FileInputStream(file2);                          ftp.storeFile(file2.getName(), input);                          input.close();                                            }                             }              }else{                  File file2 = new File(file.getPath());                  FileInputStream input = new FileInputStream(file2);                  ftp.storeFile(file2.getName(), input);                  input.close();                }          }         public static void main(String[] args) throws Exception{          FTPtest t = new FTPtest();          t.connect("", "localhost", 2121, "admin", "admin");          File file = new File("d:\\apache-jmeter-2.13.zip");          t.upload(file);       }    }    


1. 串連ftp伺服器

格式:ftp [hostname| ip-address]
a)在linux命令列下輸入: ftp 192.168.1.1

b)伺服器詢問你使用者名稱和密碼,分別輸入使用者名稱和相應密碼,待認證通過即可。

2. 下載檔案

下載檔案通常用get和mget這兩條命令。
a) get 
格式:get [remote-file] [local-file]
將檔案從遠端主機中傳送至本地主機中。
如要擷取遠程伺服器上/usr/your/1.htm,則 ftp> get /usr/your/1.htm 1.htm (斷行符號)


b) mget      
格式:mget [remote-files]
從遠端主機接收一批檔案至本地主機。
如要擷取伺服器上/usr/your/下的所有檔案,則 ftp> cd /usr/your/
ftp> mget *.* (斷行符號)


此時每下載一個檔案,都會有提示。如果要除掉提示,則在mget *.* 命令前先執行:prompt off

注意:檔案都下載到了linux主機的目前的目錄下。比如,在 /usr/my下啟動並執行ftp命令,則檔案都下載到了/usr/my下。

3.上傳檔案

a) put
格式:put local-file [remote-file]
將本地一個檔案傳送至遠端主機中。
如要把本地的1.htm傳送到遠端主機/usr/your,並改名為2.htm ftp> put 1.htm /usr/your/2.htm (斷行符號)


b) mput
格式:mput local-files
將本地主機中一批檔案傳送至遠端主機。
如要把本地目前的目錄下所有html檔案上傳到伺服器/usr/your/ 下 ftp> cd /usr/your (斷行符號)
ftp> mput *.htm (斷行符號)


注意:上傳檔案都來自於主機的目前的目錄下。比如,在 /usr/my下啟動並執行ftp命令,則只有在/usr/my下的檔案linux才會上傳到伺服器/usr/your 下。

4. 中斷連線
bye:中斷與伺服器的串連。 ftp> bye (斷行符號)

沒有命令就yum安一下啊
#yum install -y ftp

系統內容:Red Hat Enterprise Linux Server 6

[root@1-min huage]# locale             //查看當前系統的語言環境

LANG=en_US.UTF-8

LC_CTYPE="en_US.UTF-8"

LC_NUMERIC="en_US.UTF-8"

.....

 

[root@1-min huage]# locale -a          //查看系統支援的所有語言

。。。。                              //此處省略了

en_US

en_US.iso88591

en_US.iso885915

en_US.utf8

。。。。。

zh_CN

zh_CN.gb18030

zh_CN.gb2312

zh_CN.gbk

zh_CN.utf8

。。。。

 

[root@1-min huage]# source /etc/sysconfig/i18n

在不重啟的情況下重新載入i18n檔案

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.