[Tutor] FTPlib Module

Cow cow@esweeet.com
Sun, 2 Dec 2001 23:23:32 -0800 (PST)


I am currently learning to use the ftplib module, and i am getting most of it but i am running into a problem when i try to send a file.  Here is my code:

from ftplib import FTP

cow= FTP("127.0.0.1") #Pretend that that address is the address of a FTP
cow.login()
cow.cwd("/")
cow.set_pasv(0)
cow.transfercmd("STOR test1.txt")
cow.close()

when i run the code, it sends the file to the sever, but there is nothing in the file (it is blank).  i am learning from this explanation:

transfercmd(cmd[, rest])
 
Initiate a transfer over the data connection. If the transfer is active, send a "EPRT" or "PORT" command and the transfer command specified by cmd, and accept the connection. If the server is passive, send a "EPSV" or "PASV" command, connect to it, and start the transfer command. Either way, return the socket for the connection. 

i get most of it, but when i actually use code, it only sends a blank file.  can someone please clear up how i can get my code to send the file with its data in it?

Thanks
-Ryan




_____________________________________________________________
Free eSweeet Mail - http://www.esweeet.com