Hints about a script that read ftp contents ....
simon place
simon_place at whsmithnet.co.uk
Thu Aug 7 18:39:04 EDT 2003
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.
More information about the Python-list
mailing list