faqts : Computers : Programming : Languages : Python : Common Problems : FTP

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

11 of 25 people (44%) answered Yes
Recently 4 of 10 people (40%) answered Yes

Entry

How do I get a file list via an ftp connection?

Jun 27th, 2000 05:46
Kenroy Harrison, unknown unknown, Thomas Weholt


Here's a sample from the FTPLIB Library Reference page:

http://www.python.org/doc/current/lib/module-ftplib.html

from ftplib import FTP
ftp = FTP('ftp.python.org')   # connect to host, default port
ftp.login()               # user anonymous, passwd user@hostname
ftp.retrlines('LIST')     # list directory contents
ftp.quit()


The file Tools/scripts/ftpmirror.py in the Python source distribution is
a script that can mirror FTP sites, or portions thereof, using the
ftplib module. It can be used as an extended example that applies this
module.