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

Hi,
I am trying to write a backup tool with Perl and Net::FTP module.
I have one central Windows XP Professional server with large disk space and have several Windows NT machines.
I would like to ftp each NT machine and get 4 or 5 files to the XP server.

my sample code is below...
my problem is timeout...it is starting to get files but so many times I am getting below error message;

"Timeout at /usr/lib/perl5/5.8.5/Net/FTP.pm line 503"

and after that ftp session disconnect.

I increased the Timeout value but nothing is changed.
Do you have any idea ? What is wrong ?
Could you please help me to solve this issue...

Thank you very much for your valuable help...
======================================================== #!/usr/bin/perl -w use strict; use warnings; use Net::FTP; use Net::Telnet (); sub ftpnd { my $host = $_[0]; my $Fusername = "XXXXX"; my $Fpasswd = "yyyyyy"; my $ftpobj = Net::FTP -> new ($host, Debug => 0, Timeout => 240) or di +e "Cannot connect $@"; $ftpobj -> login($Fusername,$Fpasswd) or die "Cannot Login ",$ftpobj-> +message; ; $ftpobj -> cwd ("ftpvol/relfsw2"); $ftpobj -> binary; my @Flist = $ftpobj->ls("*"); foreach my $file (@Flist) { $ftpobj->get($file) or die "can't get file: $!"; } $ftpobj -> quit; return; } ftpnd("10.202.14.130"); } =========================================================

Replies are listed 'Best First'.
Re: Net::FTP Timeout problem from Windows NT machine...
by nemo (Sexton) on Aug 20, 2007 at 12:58 UTC
    It sounds as if you're network may be causing these problems. In the code below remove: or die "can't get file: $!" and maybe use a loop to ensure that timeout errors are anticipated and the get reexecuted?
    foreach my $file (@Flist) { $ftpobj->get($file) or die "can't get file: $!"; }
Re: Net::FTP Timeout problem from Windows NT machine...
by syphilis (Archbishop) on Aug 20, 2007 at 13:06 UTC
    "Timeout at /usr/lib/perl5/5.8.5/Net/FTP.pm line 503"

    That's a very unusual perl location and architecture for a Windows machine. Still .... nothing wrong with that, I guess.

    Which version of Net::FTP ? ( perl -MNet::FTP -e "print $Net::FTP::VERSION" ) And what does line 503 contain ?

    Cheers,
    Rob
      syphilis:

      The cygwin installation (which is what I use) provides a file system similar to Unix. In fact, my Net::FTP is at /usr/lib/perl5/5.8/Net/FTP.pm. Sounds like I need to upgrade my perl....

      ...roboticus

        Aaah, yes ... the op didn't say he was running a native Windows build of perl ... that was just me assuming something I shouldn't have :-)

        Cheers,
        Rob
      Hi Rob,
      first of all, sorry for my late reply and thanks for your quick reply.
      at the end, here is the my answers;
      my versin of Net::FTP is 2.75 which is result for (  perl -MNet::FTP -e "print $Net::FTP::VERSION")
      and I am sorry to put wrong error line, actually I copied my code to the another Linux box and tried there. But I got still same or above Timeout message above.
      finally, The correct error message in the Windows machine is;  Timeout at D:/perl/lib/Net/FTP.pm line 503 and the line 503 is  last unless $len = $data->read($buf,$blksize); ok. I think, I answwered all questions... How can I proceed to solve this issue ? Thank you very much for your quick reply and answers... Bulent Sahin.
Re: Net::FTP Timeout problem from Windows NT machine...
by rpanman (Scribe) on Aug 20, 2007 at 17:09 UTC
    It might be worth turning on debugging by setting "Debug" to 1 when creating the Net::FTP object. If you do that and then post the output for a bad file maybe we can be of more help.

    Good to see someone using Perl to handle Ericsson switch backups :-)
      I have the same problem with SUA PERL 5.8.8 Hava you find any solution ?