Gangabass:

Yes, it's unfortunate that the FTP protocol doesn't specify the format for the ls and dir commands. Certainly there would be differences between the available information on different operating systems, but rather than leaving it totally unspecified, I'd've preferred that they have a fixed set of information on the front of each line, with "extra" information in free-format afterwards so this wouldn't be a problem.

For example, the first line should be a header line (to describe the columns). Then each remaining line should have the filename, the size (if known), and date/time last changed (if known) with other information changing by OS after that. Were it specified that way, then your client could *always* use the same code to find the filenames available if it didn't care about the other information.

I have that problem frequently, as many of my programs must interface with an FTP server running on a zOS mainframe with its own peculiarities....

So you'll likely want to read 'perldoc perlfunc' and look at the entries for unpack and substr to see how to parse it.

...roboticus


In reply to Re: Parsing FTP ls command results by roboticus
in thread Parsing FTP ls command results by Gangabass

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.