Posts

Showing posts with the label ftplib

python ftp.nlst() return empty list when where are (sub)directories on the server

python ftp.nlst() return empty list when where are (sub)directories on the server My application needs to download all the directories from a remote FTP, I'm testing for the first time the python's ftplib . ftplib When I try to list all the directories in the remote FTP with the command ftp.nlst() it return an empty list. I know for sure that the directory is not empty because this command: ftp.retrlines('list') returned an object displaying the names of the subfolders inside the directory. ftp.nlst() ftp.retrlines('list') While I was testing I tried other commands like ftp.cwd('/other-dir/') or ftp.pwd() , but none of these seems to work. ftp.cwd('/other-dir/') ftp.pwd() This is the code that I'm using to display the list of subdirectories: from ftplib import FTP def ftpConnection(): ftp = FTP('ftp-address') ftp.login('user', 'password') lista = ftp.nlst() return (lista) print(ftpConnection()) Outpu...