I'm trying to automatically upload a data file to my server, from my clients, every 5 seconds
I tried net::ftp code, but it never makes it past the stor command.

My code is here:
$ftpobj = Net::FTP -> new ("server.com",Debug =>1,Timeout=>60); $ftpobj -> login("user","pass"); $ftpobj -> binary; $ftpobj -> cwd ("/Users/a/code/perl/ftptest"); $ftpobj -> delete ("/Users/a/code/perl/ftptest/testfile.txt"); $ftpobj -> put ("/Users/a/code/perl/testfile.txt","/Users/a/code/perl/ +ftptest/testfile.txt"); $ftpobj -> quit; print "file size ",-s "testfile.txt"," bytes\n";

When I use console ftp to send the file to the same server, it uploads inside of a second or two. Using the net::ftp lib, it's timing out. I must be doing something wrong as it's only 23 bytes. The Debug message is below:
Net::FTP>>> Net::FTP(2.75) Net::FTP>>> Exporter(5.567) Net::FTP>>> Net::Cmd(2.26) Net::FTP>>> IO::Socket::INET(1.26) Net::FTP>>> IO::Socket(1.27) Net::FTP>>> IO::Handle(1.21) Net::FTP=GLOB(0x889f84)<<< 220 server.com FTP server (lukemftpd 1.1) r +eady. Net::FTP=GLOB(0x889f84)>>> user a Net::FTP=GLOB(0x889f84)<<< 331 Password required for a. Net::FTP=GLOB(0x889f84)>>> PASS .... Net::FTP=GLOB(0x889f84)<<< 230- Net::FTP=GLOB(0x889f84)<<< Welcome to Darwin! Net::FTP=GLOB(0x889f84)<<< 230 User a logged in. Net::FTP=GLOB(0x889f84)>>> TYPE I Net::FTP=GLOB(0x889f84)<<< 200 Type set to I. Net::FTP=GLOB(0x889f84)>>> CWD /Users/a/code/perl/ftptest Net::FTP=GLOB(0x889f84)<<< 250 CWD command successful. Net::FTP=GLOB(0x889f84)>>> DELE /Users/a/code/perl/ftptest/testfile.tx +t Net::FTP=GLOB(0x889f84)<<< 250 DELE command successful. Net::FTP=GLOB(0x889f84)>>> ALLO 23 Net::FTP=GLOB(0x889f84)<<< 202 ALLO command ignored. Net::FTP=GLOB(0x889f84)>>> PORT 69,82,120,222,214,103 Net::FTP=GLOB(0x889f84)<<< 200 PORT command successful. Net::FTP=GLOB(0x889f84)>>> STOR /Users/a/code/perl/ftptest/testfile.tx +t Net::FTP=GLOB(0x889f84): Timeout at ftp.pl line 10 Net::FTP=GLOB(0x889f84)>>> QUIT Net::FTP=GLOB(0x889f84)<<< 425 Can't build data connection: Operation +timed out. file size 23 bytes


In reply to Net::FTP question. Better way? by ecuguru

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.