python 用pyftplib快速建設ftp

來源:互聯網
上載者:User

標籤:

先下載 svn checkout http://pysendfile.googlecode.com/svn/ pysendfile-read-onlycd pysendfile-read-only/   python setup.py buildpython setup.py install svn checkout http://pyftpdlib.googlecode.com/svn/trunk/ pyftpdlib-read-only  cd pyftpdlib-read-only/ python setup.py buildpython setup.py install

vim ftpserver.py

#!/usr/bin/env pythonfrom pyftpdlib import ftpserverauthorizer = ftpserver.DummyAuthorizer()authorizer.add_user("user", "12345", "/home/great", perm="elradfmw")authorizer.add_anonymous("/home/great")handler = ftpserver.FTPHandlerhandler.authorizer = authorizeraddress = ("127.0.0.1", 21)ftpd = ftpserver.FTPServer(address, handler)ftpd.serve_forever()

python ftpserver.py

  別人的代碼

from pyftpdlib.authorizers import DummyAuthorizerfrom pyftpdlib.handlers import FTPHandlerfrom pyftpdlib.servers import FTPServerdef main():    # Instantiate a dummy authorizer for managing 'virtual' users    authorizer = DummyAuthorizer()    # Define a new user having full r/w permissions and a read-only    # anonymous user    authorizer.add_user('user', '12345', '.', perm='elradfmwM')    authorizer.add_anonymous(os.getcwd())    # Instantiate FTP handler class    handler = FTPHandler    handler.authorizer = authorizer    # Define a customized banner (string returned when client connects)    handler.banner = "pyftpdlib based ftpd ready."    # Specify a masquerade address and the range of ports to use for    # passive connections.  Decomment in case you're behind a NAT.    #handler.masquerade_address = '151.25.42.11'    #handler.passive_ports = range(60000, 65535)    # Instantiate FTP server class and listen on 0.0.0.0:2121    address = ('', 2121)    server = FTPServer(address, handler)    # set a limit for connections    server.max_cons = 256    server.max_cons_per_ip = 5    # start ftp server    server.serve_forever()if __name__ == '__main__':    main()

文檔

http://pythonhosted.org/pyftpdlib/index.html

著作權聲明:本文為博主原創文章,未經博主允許不得轉載。

python 用pyftplib快速建設ftp

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.