FAQ
according to the info i've got reply '211' like all the '2??' replies are
confirmation of a correctly completed command?

'stat' transfers its result over the control socket, i think retrlines is
looking for a result on the data socket, which is what the 'list' command
does, or 'nlst' which just includes file names.

so:

from ftplib import FTP
ftp = FTP('ftp.python.org') # connect to host, default port
ftp.login()
a=ftp.sendcmd('stat *',a.append)
ftp.quit()
print a

or for a list;

from ftplib import FTP
ftp = FTP('ftp.python.org') # connect to host, default port
ftp.login()
a=[]
ftp.retrlines('list *',a.append)
ftp.quit()
print a

or for a file name list;

from ftplib import FTP
ftp = FTP('ftp.python.org') # connect to host, default port
ftp.login()
a=[]
ftp.retrlines('nlst *',a.append)
ftp.quit()
print a

unfortunately none of these do a recursive search if you add the extension
,so 'nlst *.pdf' only searches the current directory, but your going to have
to manipulate the list returned anyway so filtering pdf is trivial.

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 5 of 8 | next ›
Discussion Overview
grouppython-list @
categoriespython
postedAug 6, '03 at 9:45p
activeAug 12, '03 at 5:09p
posts8
users2
websitepython.org

2 users in discussion

Simon place: 4 posts Conatic: 4 posts

People

Translate

site design / logo © 2022 Grokbase