List all files using FTP

Giampaolo Rodola' gnewsg at gmail.com
Wed Apr 30 10:20:15 EDT 2008


On 6 Mar, 18:46, Anders Eriksson <andi... at gmail.com> wrote:
> Hello,
>
> I need to list all the files on myFTPaccount (multiple subdirectories). I
> don't have shell access to the account.
>
> anyone that has a program that will do this?
>
> // Anders
> --
> English is not my first, or second, language
> so anything strange, or insulting, is due to
> the translation.
> Please correct me so I may improve my English!

If you mean listing ALL files including those contained in sub
directories if the server supports globbing you can issue a "STAT *"
command and receive the list of all files on the command channel in an
"ls -lR *"-like form.
Not tested:

>>> import ftplib
>>> f = ftplib.FTP()
>>> f.connect('ftpserver.domain', 21)
>>> f.login()
>>> f.sendcmd('STAT *')
an "ls -lR *" is expected to come



More information about the Python-list mailing list