Trees Indices Help
Python Standard Library
Module ftplib
[]

Module ftplib

An FTP client class and some helper functions.

Based on RFC 959: File Transfer Protocol (FTP), by J. Postel and J. Reynolds

Example:

>>> from ftplib import FTP
>>> ftp = FTP('ftp.python.org') # connect to host, default port
>>> ftp.login() # default, i.e.: user anonymous, passwd anonymous@
'230 Guest login ok, access restrictions apply.'
>>> ftp.retrlines('LIST') # list directory contents
total 9
drwxr-xr-x 8 root wheel 1024 Jan 3 1994 .
drwxr-xr-x 8 root wheel 1024 Jan 3 1994 ..
drwxr-xr-x 2 root wheel 1024 Jan 3 1994 bin
drwxr-xr-x 2 root wheel 1024 Jan 3 1994 etc
d-wxrwxr-x 2 ftp wheel 1024 Sep 5 13:43 incoming
drwxr-xr-x 2 root wheel 1024 Nov 17 1993 lib
drwxr-xr-x 6 1094 wheel 1024 Sep 13 19:07 pub
drwxr-xr-x 3 root wheel 1024 Jan 3 1994 usr
-rw-r--r-- 1 root root 312 Aug 1 1994 welcome.msg
'226 Transfer complete.'
>>> ftp.quit()
'221 Goodbye.'
>>>

A nice test that reveals some of the network dialogue would be: python ftplib.py -d localhost -l -p -l

Classes [hide private]
Error error_reply error_temp error_perm error_proto FTP
An FTP client class. Netrc
Class to parse & provide access to 'netrc' format files.
Functions [hide private]
parse150(resp)
Parse the '150' response for a RETR request.
parse227(resp)
Parse the '227' response for a PASV request.
parse229(resp, peer)
Parse the '229' response for a EPSV request.
parse257(resp)
Parse the '257' response for a MKD or PWD request.
print_line(line)
Default retrlines callback to print a line.
ftpcp(source, sourcename, target, targetname='', type='I')
Copy file from one FTP-instance to another.
test()
Test program.
Variables [hide private]
MSG_OOB = 1 FTP_PORT = 21 all_errors = (<class 'ftplib.Error'>, <class 'socket.error'>, ... CRLF = '\r\n' _150_re = None _227_re = None

Imports: os, sys, socket


Function Details [hide private]

parse150(resp)

Parse the '150' response for a RETR request. Returns the expected transfer size or None; size is not guaranteed to be present in the 150 message.

parse227(resp)

Parse the '227' response for a PASV request. Raises error_proto if it does not contain '(h1,h2,h3,h4,p1,p2)' Return ('host.addr.as.numbers', port#) tuple.

parse229(resp, peer)

Parse the '229' response for a EPSV request. Raises error_proto if it does not contain '(|||port|)' Return ('host.addr.as.numbers', port#) tuple.

parse257(resp)

Parse the '257' response for a MKD or PWD request. This is a response to a MKD or PWD request: a directory name. Returns the directoryname in the 257 reply.

test()

Test program. Usage: ftp [-d] [-r[file]] host [-l[dir]] [-d[dir]] [-p] [file] ...

-d dir -l list -p password


Variables Details [hide private]

all_errors

Value:
(<class 'ftplib.Error'>,
 <class 'socket.error'>,
 <type 'exceptions.IOError'>,
 <type 'exceptions.EOFError'>)

Trees Indices Help
Python Standard Library

AltStyle によって変換されたページ (->オリジナル) /