ftplib.error_perm:502命令未实现(python)

时间:2013-09-22 11:12:02

标签: python ftp

我想获取ftp目录中的文件夹列表,但是我收到以下错误:

directory list of folder  /myfolder
Traceback (most recent call last):
  File "./run.py", line 12, in <module>
    folderList = connection.nlst()
  File "/usr/local/lib/python2.7/ftplib.py", line 506, in nlst
    self.retrlines(cmd, files.append)
  File "/usr/local/lib/python2.7/ftplib.py", line 429, in retrlines
    conn = self.transfercmd(cmd)
  File "/usr/local/lib/python2.7/ftplib.py", line 368, in transfercmd
    return self.ntransfercmd(cmd, rest)[0]
  File "/usr/local/lib/python2.7/ftplib.py", line 331, in ntransfercmd
    resp = self.sendcmd(cmd)
  File "/usr/local/lib/python2.7/ftplib.py", line 244, in sendcmd
    return self.getresp()
  File "/usr/local/lib/python2.7/ftplib.py", line 219, in getresp
    raise error_perm, resp
ftplib.error_perm: 502 Command not implemented

这是山寨代码:

#!/usr/bin/python

import ftplib

connection = ftplib.FTP("10.0.99.11")
#connection.set_pasv(False)
connection.login(user='abc', passwd='1234')
rootDir = "/myfolder"
connection.cwd(rootDir)
print "directory list of folder ",rootDir
#connection.retrlines('LIST')
folderList = connection.nlst()
for folderEntry in folderList:
    print folderEntry
print "end of list"

# close connection
connection.quit()

感谢您的帮助以及您的任何信息或想法。

0 个答案:

没有答案