ftp putting information in a variable

Discussion in 'Python' started by Arne, Apr 8, 2006.

  1. Arne

    Arne Guest

    Hello!I am looking for a way to put ftp returns in a variable.My OS is XP and I want to get the owner of a file. So I have to connect to ftp. But I am stacked with how I can receive this information and put it in a variable.Thanks! ArneHere is a intend of doing thisfrom ftplib import FTP
    ftp = FTP('ftp.cwi.nl') # connect to host, default port
    ftp.login() # user anonymous, passwd anonymous
    ftp.retrlines('LIST') # list directory contents.....
    Arne, Apr 8, 2006
    #1
    1. Advertising

  2. Hi Arne,

    On 2006-04-08 12:44, Arne wrote:
    > I am looking for a way to put ftp returns in a variable.
    >
    > My OS is XP and I want to get the owner of a file. So I have to
    >
    > connect to ftp. But I am stacked with how I can receive this
    > information and put it in a variable.


    you can use a library to handle that. One of them is ftputil
    ( http://ftputil.sschwarzer.net/ ), which I know because I'm its
    author. ;-) Surely, there are alternatives. You can search the
    Python package index at http://www.python.org/pypi .

    With ftputil, you would do

    import ftputil
    host = ftputil.FTPHost(hostname, user, password)
    # st_uid is used by Python's os.(l)stat, but it's a string here,
    # not an integer
    user = host.stat(file_or_dir).st_uid
    ....
    host.close()

    This works only if the output of the FTP LIST command contains
    the user information (which is often the case).

    ftputil is pure Python and should work on OS X without problems.

    If you think that installing/using an additional library is
    overkill, you can extract the necessary parser code from the file
    ftp_stat.py or write your own parser.

    Stefan
    Stefan Schwarzer, Apr 11, 2006
    #2
    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. someone

    FTP over SSL vs FTP over SSH

    someone, Apr 24, 2004, in forum: Java
    Replies:
    1
    Views:
    4,579
    iksrazal
    Apr 25, 2004
  2. Saurabh
    Replies:
    6
    Views:
    4,520
    Chris Smith
    May 30, 2004
  3. Per-Olof Nilsson

    How to aviod putting url-information in history-list.

    Per-Olof Nilsson, Feb 12, 2004, in forum: ASP General
    Replies:
    3
    Views:
    109
  4. D. Buck
    Replies:
    2
    Views:
    477
    D. Buck
    Jun 29, 2004
  5. Madame Blablavatsky

    putting information from iframe in hidden textfiel

    Madame Blablavatsky, Sep 1, 2005, in forum: Javascript
    Replies:
    1
    Views:
    99
    Madame Blablavatsky
    Sep 1, 2005
Loading...

Share This Page