943,560 Members | Top Members by Rank

Ad:
  • Perl Discussion Thread
  • Unsolved
  • Views: 1747
  • Perl RSS
Apr 2nd, 2009
0

ftp-> quit fails with Bad file number error for some servers

Expand Post »
Hi

I have written a ftp script in perl.It seems to work fine but for some servers it throws an error "Bad file number" while trying to close the connection.What can be the reason for this?How should I resolve it? Following is the ftp section from my code:

Perl Syntax (Toggle Plain Text)
  1. if (!$ftp->get($ftp_FileList, $output_file_path."$ftp_FileList"))
  2. {
  3. $logger->error("Status: Can't Get File $ftp_FileList \n");
  4. unlink($output_file_path.$ftp_FileList);
  5. next;
  6. }else
  7. {$logger->info("Update the cache file");
  8. print CASHE_WRITE "$ftp_FileList\n";
  9. $logger->info("Updated the cache file");
  10. }
  11. $ftp->quit or die $logger->error("Couldn't quit ftp session\n"),exit;
  12. $logger->info("---------------------------Quiting FTP----------------------------\n");
  13. close CASHE_WRITE || $logger->error("Can't close $cacheFile opened in write mode\n");

Thanks
Debangana
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Debangana is offline Offline
5 posts
since Apr 2009
Apr 2nd, 2009
0

Re: ftp-> quit fails with Bad file number error for some servers

Hi

I tried enabling the debug mode and here is what the code logs:

Net::FTP=GLOB(0x40b6b868)<<< 226 Transfer complete.
Net::FTP=GLOB(0x40b6b868)>>> QUIT
Net::FTP=GLOB(0x40b6b868)<<< 221-You have transferred 131595 bytes in 1 files.
Net::FTP: Unexpected EOF on command channel

Please suggest on how to resolve this problem.

Thanks
Debangana
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Debangana is offline Offline
5 posts
since Apr 2009
Apr 4th, 2009
0

Re: ftp-> quit fails with Bad file number error for some servers

FTP uses two ports (typically 20 and 21). One of those ports is meant to handle all of your commands. The other one, is meant to return data to you. If you receive an EOF on the command channel, it likely means that the command channel (port 21) is indicated that the file transfer has completed successfully, and it's telling you that it's done sending the file (EOF). I've never used the ftp module, so I can't tell you where to fix it... doing it with just sockets, I'd make the code simply discard the EOF, and use it to inform me to close the file handle....you'll want to look at the ftp module's properties, or see if you can error trap the error and discard it.
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004
Apr 15th, 2009
0

Re: ftp-> quit fails with Bad file number error for some servers

Sorry for the late reply. Thanks for your suggestion. I will try to investigate more into this.

Regards
Debangana
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Debangana is offline Offline
5 posts
since Apr 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Perl Forum Timeline: Perl Equivalent of PHP Code ...
Next Thread in Perl Forum Timeline: Flat file output





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC