getting files over ftp

J

Joe

How can you grab files over an ftp connection using ftplib? I can
make the connection, browse to the directory, view directory, but
can't copy over the files.

Thanks
 
K

Kevin Ballard

How can you grab files over an ftp connection using ftplib? I can
make the connection, browse to the directory, view directory, but
can't copy over the files.

Thanks

How about the retrbinary() function?
 
T

Tom Hanks

How can you grab files over an ftp connection using ftplib? I can
make the connection, browse to the directory, view directory, but
can't copy over the files.

Thanks

def ftp_download(host, user, pswd, ftpdir, filename):
"""Downloads a single file from an FTP server"""
ftp = ftplib.FTP()
ftp.connect( host )
ftp.login ( user , pswd )
ftp.cwd ( ftpdir )

f = file( filename , "wb" )
ftp.retrbinary("RETR " + filename, f)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,176
Messages
2,570,947
Members
47,498
Latest member
log5Sshell/alfa5

Latest Threads

Top