[Tutor] using ftplib

Chad Crabtree flaxeater at yahoo.com
Thu Jun 10 11:00:25 EDT 2004


--- John Fabiani <jfabiani at yolo.com> wrote:
> Hi,
> 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
> #test FTP LOGIN
>
remote=ftplib.FTP(host='63.204.66.140',user='username',passwd='password')
> remote.getwelcome()
> filename=open("C:\\brssoserv.prg",'rb')
> remote.sendcmd('PASV')
> remote.storbinary("STOR brssoserv.prg",filename)
> #myans=remote.size('booktown.sql')
> remote.close()
> 
> 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 192.168.1.195
> 
> 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>passive
> FTP>binary
> 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
> John
Ok I don't see anything wrong with you code.   HOwever
it turns out 425 is an ftp error sent by the server. 
Look at this
http://www.netsys.com/fwtk/2000/02/msg00042.html
Has a thread on it which may be relevant also this
http://www.jsiinc.com/SUBF/TIP2900/rh2936.htm

Perhaps you should try the PUT command instead.

Good luck.


	
		
__________________________________
Do you Yahoo!?
Friends.  Fun.  Try the all-new Yahoo! Messenger.
http://messenger.yahoo.com/ 



More information about the Tutor mailing list