Simple FTP Client
daniel at dittmar.net
Sun Feb 2 02:52:28 CET 2003
> I'm trying to write a very small script that will connect to a host and
> download a file (much more to come in the future). The following is what
> I've assembled from the ftplib manual.
> from ftplib import FTP
> ftp = FTP('ftp.thepaperclipse.com')
> ftp.login("drgoslee", "patribus")
> ftp.retrbinary('RETR ./httpdocs/dbbackups/PaperClipse_sql.tar.gz');
> Naturally however, I am getting an error.
> TypeError: retrbinary() takes at least 3 arguments (2 given)
> It makes sense, but I don't know how to correct it. What do I need to set
> the other parameter(s) to? Any suggestions would be greatly appreciated.
retrbinary(command, callback[, maxblocksize[, rest]])
Retrieve a file in binary transfer mode. command should be an
appropriate "RETR" command: 'RETR filename'. *The callback function is
called for each block of data received, with a single string argument
giving the data block.*
One good kind of callback is the write method of a stream:
stream = open ('PaperClipse_sql.tar.gz', 'wb')
ftp.retrbinary ('RETR ....', stream.write)
More information about the Python-list