[Tutor] ftplib

Remco Gerlich scarblac@pino.selwerd.nl
Tue, 6 Jun 2000 12:56:25 +0200


On Tue, Jun 06, 2000 at 01:43:52AM -0400, Andres Gelabert wrote:
> By all means:
> 
> from ftplib import FTP
> ftp = FTP()
> ftp.connect("OtherServer")
> ftp.login("AccountOnOtherServer", "CorrespondingPassword")
> ftp.cwd("DirectoryIWant")
> ftp.retrbinary("retr DesiredFile", open("DesiredFile", "wb").write)
> 
> # The above results in the file's successful transfer
> # Now, I try only one of the following, with the described respective errors
> 
> quit()
> close()
> sendcmd("bye")

You need to tell Python where to find those commands, ie in the 'ftp'
object, just like the other commands. Ie, ftp.quit(), ftp.close(), and
ftp.sendcmd().

In the interpreter, 'quit' is actually initialized to the string 'Use Ctrl-D
(i.e. EOF) to exit.'. Therefore, you get an error when you try to use it as 
a function. I didn't know about that. Odd.

The others are simply unknown in this namespace, so you get a NameError.

-- 
Remco Gerlich,  scarblac@pino.selwerd.nl