ftplib and FTP Objects...
jic
cabrera at wrc.xerox.com
Thu Apr 11 13:47:42 EDT 2002
Greetings!
I have tried all day to get the storbinary object to work and nothing.
Here is the code:
def FTPaFileToFP(self,mypath,FP_IP,user,pw):
ftp = FTP(FP_IP)
ftp.login(user,pw) # connect to host, default port
ftp.mkd('DOC.XSM')
ftp.pwd()
ftp.cwd('DOC.XSM')
WorkFiles = glob.glob (mypath + '\*.*')
WorkFiles.sort()
for file in WorkFiles:
(junk,fname) = os.path.split(file)
print fname
f = open(file,'rb')
ftp.storbinary('STOR ' + fname,f.read )
f.close()
ftp.quit()
Here is what I get:
Traceback (most recent call last):
File "C:\myprograms\python\test\TIFs2DS.py", line 235, in ?
c.FTPaFileToFP(mypath,'fpsdk','USER','pw')
File "C:\myprograms\python\test\TIFs2DS.py", line 225, in FTPaFileToFP
ftp.storbinary('STOR ' + fname,f.read )
File "C:\Utils\Python21\lib\ftplib.py", line 371, in storbinary
conn = self.transfercmd(cmd)
File "C:\Utils\Python21\lib\ftplib.py", line 296, in transfercmd
return self.ntransfercmd(cmd, rest)[0]
File "C:\Utils\Python21\lib\ftplib.py", line 273, in ntransfercmd
host, port = parse227(self.sendcmd('PASV'))
File "C:\Utils\Python21\lib\ftplib.py", line 229, in sendcmd
return self.getresp()
File "C:\Utils\Python21\lib\ftplib.py", line 202, in getresp
raise error_perm, resp
ftplib.error_perm: 500 Unrecognized command
I've tried setting up the buffer for read() and nothing. Has anyone gotten the
storbinary to work?
thanks much!
josé
More information about the Python-list
mailing list