- 1、本文档共17页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
金枫 Intranet 网安实验室 作者:枫无眠
python 与常用文件传输协议
枫无眠
maple5218@163.com
关键词 :python,linux,Ylmfos,Ubuntu,ftp,sftp,samba.
0 引言
文件操作在我们测试和开发当中都有用到,本文总结了最常见的文件传输的方式。
ftp — 互联网中使用广泛的协议
Sftp — linux 系统中使用最广泛的协议
Samba--liunux 和 windows 这间使用最广泛的协议。
1 ftp 协议
ftp 全称文件传输协议,是在互联网中使用广泛的协议。基于 tcp 协议,缺省端口 21.
1.1 ftplib -- FTP protocol client
This module defines the class FTPand a few related items. The
FTPclass implements the client side of the FTP protocol. You can use
this to write Python programs that perform a variety of automated FTP
jobs, such as mirroring other ftp servers. It is also used by the
module urllib to handle URLs that use FTP. For more information on FTP
(File Transfer Protocol), see Internet RFC959.
Heres a sample session using the ftplib module:
from ftplib import FTP
ftp = FTP(ftp.cwi.nl) # connect to host, default port
ftp.login() # user anonymous, passwd anonymous@
ftp.retrlines(LIST) # list directory contents
total 24418
drwxrwsr-x 5 ftp-usr pdmaint 1536 Mar 20 09:48 .
dr-xr-srwt 105 ftp-usr pdmaint 1536 Mar 21 14:32 ..
-rw-r--r-- 1 ftp-usr pdmaint 5305 Mar 20 09:48 INDEX
.
版权所有 欢迎转载 1/17
金枫 Intranet 网安实验室 作者:枫无眠
.
.
ftp.retrbinary(RETR README, open(README, wb).write)
226 Transfer complete.
ftp.quit()
The module defines the following items:
class FTP
host , user ,passwd , acct )
[ [ [
文档评论(0)