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

I've got a script that has been throwing an intermittant error for the past month. Before that, it ran fine for over two years. The script connects to an ftp server and retrieves a bunch of binary files then processes them into our database. It runs once/hour and now it's failing about 50% of the time.

The error message is 'bad file number' and it's failing while attempting to connect to the remote server. The section of code where it fails is:

my $ftp = Net::FTP->new( $ftpHost, Debug => 0 ); if( ! $ftp ) { LogUtils::error( "Couldn't connect to '$ftpHost' ($@ : $!)" ); print( "Couldn't connect to '$ftpHost' ($@ : $!)\n" ); exit( -1 ); }

And the actual message that gets logged is "Couldn't connect to 'ftp.meteorlogix.com' ( : Bad file number)".

The system it runs on is Solaris. Oddly, the exact same script runs in our dev environment just fine (connects to the same remote server, once/hour). It has also run without errors every time that I've manually run it.

I've set Debug to 1 and captured the output:

Net::FTP: Net::FTP(2.65) Net::FTP: Exporter(5.562) Net::FTP: Net::Cmd(2.21) Net::FTP: IO::Socket::INET(1.25) Net::FTP: IO::Socket(1.26) Net::FTP: IO::Handle(1.21) Net::FTP: Unexpected EOF on command channel at /local/rtp/rtp-0.4/bin/ +meteorlogix line 215

That output doesn't change when I add the Passive => 1 to the constructor options either.

Any ideas??

Dave

Replies are listed 'Best First'.
Re: ftp connection problem
by gellyfish (Monsignor) on Aug 18, 2006 at 12:54 UTC

    Probably something changed on the network, if the Perl program hasn't changed and the modules haven't changed then it's got to be external to the program. Set the debugging on the Net::FTP constructor and examin the logs on the FTP server.

    /J\

A reply falls below the community's threshold of quality. You may see it by logging in.