my administrator is rather particular about the way i tie to my FTP server from my WWW server for security reasons. hence, i'm trying to write a "canned" FTP program that gets the directory and files from a remote server from my web server to my perl program for manipulation. i get everything working perfectly up to the point of the "LIST". my connection stales and i get nothing at this point. please check the following example and help me over this last "hump" ?
$FTPdServer = '192.168.0.1'; $System[0] = '\0'x4; $System[1] = '\0'x16; socket (FTP, AF_INET, SOCK_STREAM, getprotobyname('tcp')); connect (FTP, pack('S n a4 x8', AF_INET, 21, (gethostbyname($FTPdServe +r)) [4])); $System[0] = (unpack('S n a4 x8', getsockname(FTP)))[2]; $System[1] = pack('S n a4 x8', AF_INET, 0, $System[0]); select (FTP); $| = 1; select (STDOUT); sysread (FTP, $FormData, 1024); print STDOUT "$FormData\n"; sysread (FTP, $FormData, 1024); print STDOUT "$FormData\n"; print FTP "USER webserver\r\n"; sysread (FTP, $FormData, 1024); print STDOUT "$FormData\n"; print FTP "PASS password\r\n"; sysread (FTP, $FormData, 1024); print STDOUT "$FormData\n"; print FTP "CWD Weaving\r\n"; sysread (FTP, $FormData, 1024); print STDOUT "$FormData\n"; socket (IOS, AF_INET, SOCK_STREAM, getprotobyname('tcp')); bind (IOS, pack('S n a4 x8', AF_INET, 0, (gethostbyname($FTPdServer)) +[4])); ($System[2], $System[3], @tBuffer) = unpack("S n C C C C x8", getsockn +ame(IOS)); push(@tBuffer, ($System[3] >> 8) & 0x00ff); push(@tBuffer, $System[3] & 0x00ff); $System[4] = join(',', @tBuffer); listen (IOS, 1); print FTP "PORT $System[4]\r\n"; sysread (FTP, $FormData, 1024); print STDOUT "$FormData\n"; print FTP "LIST\r\n"; sysread (FTP, $FormData, 1024); print STDOUT "$FormData\n"; ### at this point the FTP server says; ### "opening for ascii data transfer" ### then hangs infinetly when i try the ### accept (DATA,IOS) and try to read ### from <DATA> port/file close (IOS); print FTP "QUIT\r\n"; sysread (FTP, $FormData, 1024); print STDOUT "$FormData\n"; close (FTP);

In reply to "canned" FTP by PriNet

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.