home *** CD-ROM | disk | FTP | other *** search
- <TITLE>ftplib -- Python library reference</TITLE>
- Next: <A HREF="../g/gopherlib" TYPE="Next">gopherlib</A>
- Prev: <A HREF="../h/httplib" TYPE="Prev">httplib</A>
- Up: <A HREF="../i/internet_and_www" TYPE="Up">Internet and WWW</A>
- Top: <A HREF="../t/top" TYPE="Top">Top</A>
- <H1>10.4. Standard Module <CODE>ftplib</CODE></H1>
- This module defines the class <CODE>FTP</CODE> and a few related items. The
- <CODE>FTP</CODE> class 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 <CODE>urllib</CODE> to handle URLs that use FTP. For
- more information on FTP (File Transfer Protocol), see Internet RFC
- 959.
- <P>
- Here's a sample session using the <CODE>ftplib</CODE> module:
- <P>
- <UL COMPACT><CODE>>>> from ftplib import FTP<P>
- >>> ftp = FTP('ftp.cwi.nl') # connect to host, default port<P>
- >>> ftp.login() # user anonymous, passwd user@hostname<P>
- >>> ftp.retrlines('LIST') # list directory contents<P>
- total 24418<P>
- drwxrwsr-x 5 ftp-usr pdmaint 1536 Mar 20 09:48 .<P>
- dr-xr-srwt 105 ftp-usr pdmaint 1536 Mar 21 14:32 ..<P>
- -rw-r--r-- 1 ftp-usr pdmaint 5305 Mar 20 09:48 INDEX<P>
- .<P>
- .<P>
- .<P>
- >>> ftp.quit()<P>
- </CODE></UL>
- The module defines the following items:
- <P>
- <DL><DT><B>FTP</B> ([<VAR>host</VAR>[, <VAR>user</VAR>, <VAR>passwd</VAR>, <VAR>acct</VAR>]]) -- function of module ftplib<DD>
- Return a new instance of the <CODE>FTP</CODE> class. When
- <VAR>host</VAR> is given, the method call <CODE>connect(<VAR>host</VAR>)</CODE> is
- made. When <VAR>user</VAR> is given, additionally the method call
- <CODE>login(<VAR>user</VAR>, <VAR>passwd</VAR>, <VAR>acct</VAR>)</CODE> is made (where
- <VAR>passwd</VAR> and <VAR>acct</VAR> default to the empty string when not given).
- </DL>
- <DL><DT><B>all_errors</B> -- data of module ftplib<DD>
- The set of all exceptions (as a tuple) that methods of <CODE>FTP</CODE>
- instances may raise as a result of problems with the FTP connection
- (as opposed to programming errors made by the caller). This set
- includes the four exceptions listed below as well as
- <CODE>socket.error</CODE> and <CODE>IOError</CODE>.
- </DL>
- <DL><DT><B>error_reply</B> -- exception of module ftplib<DD>
- Exception raised when an unexpected reply is received from the server.
- </DL>
- <DL><DT><B>error_temp</B> -- exception of module ftplib<DD>
- Exception raised when an error code in the range 400--499 is received.
- </DL>
- <DL><DT><B>error_perm</B> -- exception of module ftplib<DD>
- Exception raised when an error code in the range 500--599 is received.
- </DL>
- <DL><DT><B>error_proto</B> -- exception of module ftplib<DD>
- Exception raised when a reply is received from the server that does
- not begin with a digit in the range 1--5.
- </DL>
- <H2>Menu</H2><DL COMPACT>
- <DT><A HREF="../f/ftp_objects" TYPE=Menu>FTP Objects</A>
- <DD></DL>
-