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

Reply

Join Date: Apr 2009
Posts: 5
Reputation: Debangana is an unknown quantity at this point 
Solved Threads: 0
Debangana Debangana is offline Offline
Newbie Poster

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

 
0
  #1
Apr 2nd, 2009
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:

  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
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 5
Reputation: Debangana is an unknown quantity at this point 
Solved Threads: 0
Debangana Debangana is offline Offline
Newbie Poster

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

 
0
  #2
Apr 2nd, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

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

 
0
  #3
Apr 4th, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 5
Reputation: Debangana is an unknown quantity at this point 
Solved Threads: 0
Debangana Debangana is offline Offline
Newbie Poster

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

 
0
  #4
Apr 15th, 2009
Sorry for the late reply. Thanks for your suggestion. I will try to investigate more into this.

Regards
Debangana
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Perl Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC