[Tutor] using ftplib

John Fabiani jfabiani at yolo.com
Thu Jun 10 03:30:30 EDT 2004

I'm trying to follow the python 2.1 bible "transferring files via FTP".  
I'm using a XP, SUSE9.1, and a 4.1 FreeBSD OS's to learn on. 

import ftplib
import sys
remote.storbinary("STOR brssoserv.prg",filename)

the above code creates the file name "brssoserv.prg" with zero bytes on 
the FTP host. The first issue is the "remote.sendcmd('PASV')" is command 
unknown on the FreeBSD computer.  What is the right command for the 
freeBSD computer running python 2.1 and how did you discover what the 
correct command is?

Next I get the following error
remote.storbinary("STOR johntest.log",filename)
Traceback (most recent call last):
  File "<input>", line 1, in ?
  File "C:\Python23\lib\ftplib.py", line 415, in storbinary
    conn = self.transfercmd(cmd)
  File "C:\Python23\lib\ftplib.py", line 345, in transfercmd
    return self.ntransfercmd(cmd, rest)[0]
  File "C:\Python23\lib\ftplib.py", line 327, in ntransfercmd
    resp = self.sendcmd(cmd)
  File "C:\Python23\lib\ftplib.py", line 241, in sendcmd
    return self.getresp()
  File "C:\Python23\lib\ftplib.py", line 212, in getresp
    raise error_temp, resp
error_temp: 425

The above error is from the windows computer on the same network as the 
FTP server.  But I get similar errors from the other computers too.  I 
believe the 425 is a clue and thats the local IP address.  But the 
freeBSD does not give that the same error. 

I can use FTP from all the computers and using standard commands:
FTP>put johntest.log

all works without error.  So I'm doing something wrong.  I believe I  am 
following the book but there has to be something I'm missing. 
BTW I have tried changing the 'STOR" to 'PUT' - again without success.
Thanks in advance

More information about the Tutor mailing list