Get all filenames inside a directory on FTP [Python] -


today ran big problem , because i'm new python i'm going need ask help.

i've managed connect ftp , login correctly.

ftp = ftplib.ftp('ftp.lala.com', 'username', 'pass') 

as second step move dir i'd like:

ftp.cwd("dirname") 

but run stuck.. need filenames in string / array / list / .. format able use names. i've tried os, glob, .. doesn't seem work in way. thoughts please? need every filename inside dir want , directories/files within wanted dir.

i somehow need change this

for filename in glob.glob("*.*"):     self.out(filename) 

to go path ftp.lala.com/mydir/ , filenames out (also if there folder inside mydir)

any suggestions or ideas welcome! yenthe

how about:

contents = ftp.retrlines('list')  # list cwd contents securely. 

or:

try:     files = ftp.nlst() except ftplib.error_perm, resp:     if str(resp) == "550 no files found":         print("no files in directory.") else:     raise 

contents list of items within directory can call.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -