FTPlib

Harlin Seritt harlinseritt at yahoo.com
Mon Feb 13 09:56:46 EST 2006


Using ftplib from Python I am trying to get all files in a particular
directory using ftplib and then send those same files to another ftp
server. I have tried using commands like 'get *' and 'mget *' with no
success.

I am using the following:

srcFtp = FTP(srcHost)
srcFtp.login(srcUser, srcPass)
srcDir = srcFtp.nlst('.')
for file in srcDir:
    print file[2:]
    srcFtp.transfercmd('get '+file[2:])

I've verified that I do have a connection with the ftp server and the
files as 'file[2:]' are indeed the file names.

Anyone know why I get the following error?

podcast-1.mp3
Traceback (most recent call last):
  File "podsync.py", line 17, in ?
    srcFtp.transfercmd('get '+file[2:])
  File "C:\Python24\lib\ftplib.py", line 345, in transfercmd
    return self.ntransfercmd(cmd, rest)[0]
  File "C:\Python24\lib\ftplib.py", line 327, in ntransfercmd
    resp = self.sendcmd(cmd)
  File "C:\Python24\lib\ftplib.py", line 241, in sendcmd
    return self.getresp()
  File "C:\Python24\lib\ftplib.py", line 216, in getresp
    raise error_perm, resp
ftplib.error_perm: 500 Syntax error, command unrecognized.

Thanks,

Harlin Seritt




More information about the Python-list mailing list