'Python FTP.mlsd doesn't work when passed current directory "." (ftplib.error_perm: 550 Unable to handle command)
When using mlsd I get an error when I pass '.' as the path.
import ftplib
ftp = ftplib.FTP_TLS('hostname.com', user='myusername', passwd='mypassword')
list(ftp.mlsd()) # Returns directory listing as expected
list(ftp.mlsd('.')) # Yields an error
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.10/ftplib.py", line 590, in mlsd
self.retrlines(cmd, lines.append)
File "/usr/lib/python3.10/ftplib.py", line 462, in retrlines
with self.transfercmd(cmd) as conn, \
File "/usr/lib/python3.10/ftplib.py", line 393, in transfercmd
return self.ntransfercmd(cmd, rest)[0]
File "/usr/lib/python3.10/ftplib.py", line 793, in ntransfercmd
conn, size = super().ntransfercmd(cmd, rest)
File "/usr/lib/python3.10/ftplib.py", line 359, in ntransfercmd
resp = self.sendcmd(cmd)
File "/usr/lib/python3.10/ftplib.py", line 281, in sendcmd
return self.getresp()
File "/usr/lib/python3.10/ftplib.py", line 254, in getresp
raise error_perm(resp)
ftplib.error_perm: 550 Unable to handle command
Note: The error only appears once you start to iterate over the generator, so the list() is required. (next() works too)
I thought it might be interpretting the . as a file/directory name, but if that were the case I'd expect it to say No such file or directory instead of Unable to handle command.
It appears that other people have used "." as an argument to mlsd so I'm not sure what I'm doing wrong.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
