Hi everybody!

I want to get list of files and folders with permission from ftp!

This is my code:

from ftplib import FTP

after runnig : (Output)

drwxrwxrwx 1 user group 0 Mar 01 14:29 Backup
drwxrwxrwx 1 user group 0 Mar 01 14:29 logs
drwxrwxrwx 1 user group 0 Apr 17 18:01 www

but when I run it , the "a" variable is empty! and I cannot use it.
I want to get files and folders with permissions from ftp and write these in file(a.txt)!

please help me.

This is a documented behaviour. FTP.dir() returns None. However, it calls a callback function for each line of the transfer. The default callback prints lines to stdout. You need to provide your own callback.


Can you give me simple code?

There's an example at the top of paragraph 20.11 (ftplib) of python documentation. See how a callback is passed to retrbinary. You need a similar setup for your ftp.dir() - or better ftp.retrlines('LIST', callback).