By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,276 Members | 1,951 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,276 IT Pros & Developers. It's quick & easy.

ftplib question - ftp.dir() returns something and ftp.nlst() does not

P: n/a
Hi there,

I am using the ftplib library to connect to a ftp server.
After I got connected, I can see a list of file in the current directory
using ftp.dir() or ftp.retrlines('LIST'). But using ftp.nlst() returns
an empty list which seems somehow strange to me. Here is, what I did:
from ftplib import FTP
HOST = 'my.server'
USER = 'myuser'
PASSWD = 'mypass'
ftp = FTP(HOST, USER, PASSWD)
ftp.set_pasv(0) # set active mode
ftp.dir() -r--r--r-- 1 owner group 121984 Nov 24 12:13 member.dat
-r--r--r-- 1 owner group 115 Nov 24 15:53 status.dat
-r--r--r-- 1 owner group 339 Nov 24 15:53 debug.txt
ftp.retrlines('LIST') -r--r--r-- 1 owner group 121984 Nov 24 12:13 member.dat
-r--r--r-- 1 owner group 115 Nov 24 15:53 status.dat
-r--r--r-- 1 owner group 339 Nov 24 15:53 debug.txt
'226 Transfer complete.'
ftp.nlst() []


I thought "ftp.nlst()" would return the list ['member.dat',
'status.dat', 'debug.txt']. Any idea, what is going wrong here?

Nico
Nov 24 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.