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

Discussion in 'Python' started by Nico Grubert, Nov 24, 2005.

  1. Nico Grubert

    Nico Grubert Guest

    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
     
    Nico Grubert, Nov 24, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mikael
    Replies:
    0
    Views:
    417
    Mikael
    Jul 14, 2004
  2. Nico Grubert
    Replies:
    0
    Views:
    461
    Nico Grubert
    Nov 25, 2005
  3. loial
    Replies:
    1
    Views:
    1,803
    Giampaolo Rodola'
    Dec 7, 2007
  4. Jon Bowlas

    ftplib returns EOFError

    Jon Bowlas, May 19, 2008, in forum: Python
    Replies:
    0
    Views:
    304
    Jon Bowlas
    May 19, 2008
  5. Ari Brown

    Net::FTP and ftp.dir()

    Ari Brown, Jul 16, 2007, in forum: Ruby
    Replies:
    0
    Views:
    90
    Ari Brown
    Jul 16, 2007
Loading...

Share This Page