[ftputil] Empty listdir in non empty directory

Mattias mb at bokesand.se
Thu May 4 10:10:07 CEST 2017


Thanks for your suggestion.
I made the testing program listed below and got the result also listed below.
It looks like the WinCE ftp-server doesn't respond to LIST -a.
I made some testing in ordinary commandline ftp-client and I get correct result from "dir" and "ls", but empty result from "dir -a" and "ls -a". (verified with wireshark that ftp-client issue "LIST -a" when I type "dir -a")
Is it possible to remove the -a when using ftputil?

Best Regards
Mattias



import ftplib
import ftputil
import ftputil.session

my_session_factory = ftputil.session.session_factory(
base_class=ftplib.FTP,
port=21,
encrypt_data_channel=False,
debug_level=2)

host = ftputil.FTPHost('192.168.10.83', 'ABC', '123', session_factory=my_session_factory)
names = host.listdir(host.curdir)
print (names)
host.close()



python MoveFinishedLogs3.py
*cmd* 'USER ABC'
*put* 'USER ABC\r\n'
*get* '331 User name okay, need password.\r\n'
*resp* '331 User name okay, need password.'
*cmd* 'PASS ***'
*put* 'PASS ***\r\n'
*get* '230 User logged in, proceed.\r\n'
*resp* '230 User logged in, proceed.'
*cmd* 'PWD'
*put* 'PWD\r\n'
*get* '257 "/".\r\n'
*resp* '257 "/".'
*cmd* 'CWD /'
*put* 'CWD /\r\n'
*get* '250 Requested file action okay, completed.\r\n'
*resp* '250 Requested file action okay, completed.'
*cmd* 'CWD /'
*put* 'CWD /\r\n'
*get* '250 Requested file action okay, completed.\r\n'
*resp* '250 Requested file action okay, completed.'
*cmd* 'TYPE A'
*put* 'TYPE A\r\n'
*get* '200 Command okay.\r\n'
*resp* '200 Command okay.'
*cmd* 'PASV'
*put* 'PASV\r\n'
*get* '227 Entering Passive Mode (192,168,10,83,192,35).\r\n'
*resp* '227 Entering Passive Mode (192,168,10,83,192,35).'
*cmd* 'LIST -a'
*put* 'LIST -a\r\n'
*get* '125 Data connection already open; transfer starting.\r\n'
*resp* '125 Data connection already open; transfer starting.'
*get* '226 Closing data connection. \r\n'
*resp* '226 Closing data connection. '
*cmd* 'CWD /'
*put* 'CWD /\r\n'
*get* '250 Requested file action okay, completed.\r\n'
*resp* '250 Requested file action okay, completed.'
[]

On 4 May 2017 at 04:09:33 +02:00, Rodrigo Santellan <rsantellan at gmail.com> wrote:

> Hi Mattias,
> When I had troubles with the connection I increased the debug level.
> 
> Can you try: <http://ftputil.sschwarzer.net/trac/wiki/Documentation#session-factories> creating a session factory with debug 2 and posting the output?
> Regards
> 
> 
> 
> On Wed, May 3, 2017 at 5:32 PM, Mattias <<mb at bokesand.se>> wrote:
> 
> > Hi
> > I have a problem with ftputil.
> > I get empty result fromlistdir.
> > If it matters my ftp-server runs on Windows CE 7.0 and the client running my python script runs on a raspberry pi (raspbian jessie lite)
> > 
> > 
> > host = ftputil.FTPHost('192.168.10.83', 'abc', '123')
> > names = host.listdir(host.curdir)
> > print (names)
> > 
> > returns just []
> > 
> > But:
> > # File: ftplib-example-1.py
> > import ftplib
> > ftp = ftplib.FTP("192.168.10.83")
> > ftp.login("abc", "123")
> > data = []
> > ftp.dir(data.append)
> > ftp.quit()
> > for line in data:
> > print "-", line
> > 
> > returns a long list like
> > ...
> > - 06-08-15 19:57 64505 Elekta20150608_13_48.csv
> > - 06-11-15 19:31 87932 Elekta20150611_11_14.csv
> > - 06-16-15 18:51 78498 Elekta20150616_11_37.csv
> > ...
> > 
> > 
> > Any ideas what could be wrong?
> > 
> > Thanks in advance
> > /Mattias Bokesand
> > 
> > _______________________________________________
> > ftputil mailing list
> > <ftputil at lists.sschwarzer.net>
> > 
> > <http://lists.sschwarzer.net/listinfo/ftputil>
> > 
> > 
> > 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sschwarzer.net/pipermail/ftputil/attachments/20170504/23aae5e8/attachment.html>


More information about the ftputil mailing list