How to parse directory structure from FTP LIST

Discussion in 'Perl Misc' started by lg, Aug 8, 2007.

  1. lg

    lg Guest

    I downloaded a directory listing using FTP command LIST. The listing is like
    below:
    drwxr-xr-x 2 test directory 3072 Aug 8 17:16 .
    drwxr-xr-x 4 test directory 9216 Aug 8 20:28 ..
    -rw-r--r-- 1 test directory 72 Aug 2 16:32 20155.txt
    -rw-r--r-- 1 test directory 76 Feb 14 18:02 41257.txt
    -rw-r--r-- 1 test directory 75 Aug 2 16:32 43916.txt

    First of all is the directory list standard? Does file/directory name start at
    column 56 etc?

    If not how do FTP programs parse info if it's not standardised?
    lg, Aug 8, 2007
    #1
    1. Advertising

  2. lg

    Guest

    On Aug 8, 11:08 am, lg <> wrote:

    > First of all is the directory list standard? Does file/directory name start at
    > column 56 etc?


    > If not how do FTP programs parse info if it's not standardised?


    FTP output (and even commands) differ widely between systems. For
    example, on my system (AIX), LIST is not even a valid FTP command. In
    AIX, if you do 'DIR' then you get a long listing (like you get with
    LIST), but if you do 'ls' then you get a list of only the filenames.
    Maybe your FTP program also has a command to list only the filenames.

    But if you want to really assure that the system is as bullet-proof as
    possible then you should use an FTP module such as Net::FTP instead of
    relying on the result of system commands. With a module you always
    know what to expect, and it is not affected by the vagaries of your
    particular ftp program (and it won't break if your ftp program is
    changed or upgraded and the output changes).


    --
    The best way to get a good answer is to ask a good question.
    David Filmer (http://DavidFilmer.com)
    , Aug 8, 2007
    #2
    1. Advertising

  3. lg

    lg Guest

    wrote:

    >On Aug 8, 11:08 am, lg <> wrote:
    >
    >> First of all is the directory list standard? Does file/directory name start at
    >> column 56 etc?

    >
    >> If not how do FTP programs parse info if it's not standardised?

    >
    >FTP output (and even commands) differ widely between systems. For
    >example, on my system (AIX), LIST is not even a valid FTP command. In
    >AIX, if you do 'DIR' then you get a long listing (like you get with
    >LIST), but if you do 'ls' then you get a list of only the filenames.
    >Maybe your FTP program also has a command to list only the filenames.
    >
    >But if you want to really assure that the system is as bullet-proof as
    >possible then you should use an FTP module such as Net::FTP instead of
    >relying on the result of system commands. With a module you always
    >know what to expect, and it is not affected by the vagaries of your
    >particular ftp program (and it won't break if your ftp program is
    >changed or upgraded and the output changes).


    Thank you for your reply.

    If system is only limited to those who understand LIST command is the list-file
    structure standardised/documented somewhere?
    lg, Aug 9, 2007
    #3
  4. lg <> wrote:
    > wrote:
    >
    >>On Aug 8, 11:08 am, lg <> wrote:
    >>
    >>> First of all is the directory list standard? Does file/directory name start at
    >>> column 56 etc?

    >>
    >>> If not how do FTP programs parse info if it's not standardised?



    The FTP protocol is standardised. FTP programs are not standardised.


    >>But if you want to really assure that the system is as bullet-proof as
    >>possible then you should use an FTP module such as Net::FTP


    > If system is only limited to those who understand LIST command is the list-file
    > structure standardised/documented somewhere?



    Maybe. The commands your FTP program have might be documented in the
    docs for your FTP program.

    But you have already been given the correct solution to your problem,
    namely, rely on the FTP protocol (via a module) rather than on a
    particular FTP program.

    Do you have some reason for not adopting the suggested correct solution?


    --
    Tad McClellan
    email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
    Tad McClellan, Aug 9, 2007
    #4
    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. john
    Replies:
    4
    Views:
    662
    Jim Higson
    Jun 15, 2006
  2. Barry Schwarz

    Re: How to parse this string into a list structure?

    Barry Schwarz, Nov 7, 2008, in forum: C Programming
    Replies:
    0
    Views:
    367
    Barry Schwarz
    Nov 7, 2008
  3. Saurabh Purnaye
    Replies:
    2
    Views:
    131
    Robert Klemme
    Jan 19, 2008
  4. D. Buck
    Replies:
    2
    Views:
    467
    D. Buck
    Jun 29, 2004
  5. Replies:
    2
    Views:
    257
    Rui Maciel
    Dec 12, 2012
Loading...

Share This Page