ftplib and 'LIST' command :

jack noThanks at ok.com
Thu Aug 1 06:36:22 EDT 2002


how, with the 'LIST' command,  can i find the name of each directory and 
each file? (in a list, tuple or other)
does I have to parse the response of the server? (the format of the 
response is always different)
I will want for example to obtain a list of the directories and another 
of the files, for the current directory.

PS there are the ' NLST' command which makes it possible to obtain a 
list of the repertories and files, but I want to do it with standard 
command ' LIST'

 >>> from ftplib import *
 >>> ftp = FTP('ftp.kde.org')
 >>> ftp.login()

 >>> ftp.retrlines('LIST')
total 28
drwxr-xr-x    2 root     root         4096 Apr 27  2001 bin
drwxr-xr-x    2 root     root         4096 Apr 27  2001 dev
drwxr-xr-x    2 root     root         4096 Jul 17 23:12 etc
drwxr-xr-x    2 root     root         4096 Apr 27  2001 lib
drwxr-xr-x    2 root     root         4096 May  2 10:01 msgs
drwxr-xr-x    8 root     root         4096 Jul  6 19:40 pub
drwxr-xr-x    3 root     root         4096 Apr 27  2001 usr
'226 Transfer complete.'

Thanks




More information about the Python-list mailing list