Oh most high holy ones, I am back for another lesson.

I need to FTP two files from my web server to a remote server periodically as I explained here: http://perlmonks.org/?node_id=702448

The problem I'm having is that execution from an shtml page times out occasionally which interrupts the process. Since I'm tranfering two files, I decided to see if I can shorten the execution time by doing the transfer in parallel rather than sequentially. I have written the following script to try to accomplish this:

#!/usr/bin/perl if (fork) { use Net::FTP; $ftp = Net::FTP->new("ftp.remoteserver.com", Passive => 1, Timeout + => 300, Debug => 0) or die "Cannot contact $host: $!"; $ftp->login("user1",'password1'); $ftp->binary(); $ftp->put("/home/users/web/blah/directory/file1"); $ftp->quit; } else { $ftp = Net::FTP->new("ftp.remoteserver.com", Passive => 1, Timeout + => 300, Debug => 0) or die "Cannot contact $host: $!"; $ftp->login("user2",'password2'); $ftp->binary(); $ftp->put("/home/users/web/blah/directory/file2"); $ftp->quit; } print "Content-type: text/html\n\n"; print <<"EOF"; <font face="arial" color=red> Transfer Complete! </font> EOF exit;
The script seems to save about 50% of the execution time. And early indications are that this script seems to have solved my problem. My previous script had the two transfers in sequence.

Since I'm very new to Perl scripting, after you have a look please answer the following simple questions for me:

- Does the script actually produce parallel transfer?
- Can you suggest any improvement?
Curiously, the script sends "Transfer Complete! Content-type: text/html Transfer Complete!" to my web page after completion, however, I believe I now understand why this is true. Thanks as always for your advice.

In reply to Shortening Execution Time by DrWho_100

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.