Firstly, if you're performing automated tasks on a retrieived FTP listing then you should probably be looking at NLST
rather than LIST
as noted in RFC 959 section 4.1.3:
NAME LIST (NLST)
...
This command is intended to return information that
can be used by a program to further process the
files automatically.
The Twisted documentation for LIST
says:
It can cope with most common file listing formats.
This make me suspicious; I do not like solutions that "cope". LIST
was intended for human consumption not machine processing.
If your target server supports them then you should prefer MLST
and MLSD
as defined in RFC 3659 section 7:
7. Listings for Machine Processing (MLST and MLSD)
The MLST and MLSD commands are intended to standardize the file and
directory information returned by the server-FTP process. These
commands differ from the LIST command in that the format of the
replies is strictly defined although extensible.
However, these newer commands may not be available on your target server and I don't see them in Twisted. Therefore NLST
is probably your best bet.
As to the nub of your problem, there are three likely causes:
- The processing of the returned results is incorrect (Twisted may be at fault, as you suggest, or perhaps elsewhere)
- The server is buggy and not sending a correct (complete) response
- The wrong command is being sent (unlikely with straight
NLST
/LIST
, but some servers react differently if arguments are supplied to these commands)
You can eliminate (2) and (3) and prove that the cause is (1) by looking at what is sent over the wire. If this option is not available to you as part of the Twisted API or the Pure-FTPD server logging configuration, then you may need to break out a network sniffer such as tcpdump, snoop or WireShark (assuming you're allowed to do this in your environment). Note that you will need to trace not only the control connection (port 21) but also the data connection (since that carries the results of the LIST
/NLST
command). WireShark is nice since it will perform the protocol-level analysis for you.
Good luck.