Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I have ActivePerl on a PC. When I upload files from the command line on our intranet, it goes at about 4 MB/s. But when I have a perl program do the same thing, it slows down to about 0.1 MB/s. The code is nothing fancy,
$ftp = Net::FTP->new("192.168.xx.xx") or die ("Connect failed!"); print "Connected.\n"; $ftp->login("xxx","xxx"); $ftp->cwd("/usr/db/data"); print "Uploading KO_Targ.csv.\n"; $ftp->put("KO_Targ.csv");
I've tried upgrading to the newest version of Net::FTP, still the same performance.

Replies are listed 'Best First'.
Re: Net::FTP much slower than command line ftp
by grep (Monsignor) on Jul 25, 2002 at 23:40 UTC
    Other than setting the 'BlockSize' in your constructor to something other than 10240 (I would start going smaller in 2048 increments then try larger than 10240 by 2048) - you might want to set 'Debug' and check out what is going on in the background.

    Unfortunately that is not a lot of info to get good idea of what is going on



    grep
    Just me, the boy and these two monks, no questions asked.
Re: Net::FTP much slower than command line ftp
by runrig (Abbot) on Jul 25, 2002 at 23:39 UTC
    You can try increasing the BlockSize (see the Net::FTP docs) to see if that helps any.
Re: Net::FTP much slower than command line ftp
by sparkyichi (Deacon) on Jul 25, 2002 at 23:50 UTC
    I find that the biggest gain you get from Net::FTP is the time saved with the time out. You can also use Net::Ping to check ping ability before you attempt to FTP. I see no reason that your script would take longer than your command line. I have used Net::FTP many times and have not experianced something like that. I would get out my packet sniffer and find out what is going on.

    Sparky
    FMTEYEWTK
Re: Net::FTP much slower than command line ftp
by december (Pilgrim) on Jul 26, 2002 at 02:12 UTC

    Two ideas:

    1) a csv is usually pretty small, not? To small to get accurate timing?
    2) Do you use an active or passive session? Maybe the switching takes some time, while your ftp client uses passive right away.

    I can't help you more, never used Net::FTP. Good luck...


       wouter