Ftp Error Bad File Number
NewestNodes Donate What'sNew on Jun 12, 2002 at 15:08UTC ( #173858=perlquestion: print w/replies, xml ) Need Help?? chaskins has asked for the wisdom of the Perl Monks concerning the following question: Hi, I've got a script that logs into an FTP server and I want it to download a file. It logs in ok checks the file is there but when it does the 'get' it dies with the following message " Bad file number". Heres some of the code; use Net::FTP; $address ="gamefiles.blueyonder.co.uk"; $hl_path = "/blueyondergames/halflife/patches/win32/"; $ftp = Net::FTP->new($address) or die "Can't connect:$@\n"; $ftp->login() or die "Couldn't login\n"; $ftp->cwd($hl_path) or die "Couldn't change directory to $hl-path: $!\ +n"; @lines_hl = $ftp->dir(".") or die "Can't get a list of files\n"; # lets check if the files are there. &checkFileExists("HL", @lines_hl); sub checkFileExists { print "pt = @_[0]\n"; if (@_[0] == "HL") { $patch = "11081109.exe"; } elsif (@_[0] == "CS") { $patch = "cs1415.exe"; #check this filename } print "patch = $patch\n"; foreach $file (@_) { if ($file =~ "$patch") { print "hit!\n"; &downloadfile($patch); break; } } } sub downloadfile { my $file = "@_[0]"; chomp($file); print "Downloading $file!\n"; $ftp->binary() or die "Can't change to Binary: $!\n"; #change i +t to a binary transfer. $ftp->get($file) or die "error downloading: $!\n"; $ftp->quit(); } [download] Any ideas why? Thanks Chris Comment on Bad file numberDownload Code Replies are listed 'Best First'. Re: Bad file number by Abigail-II (Bishop) on Jun 12, 2002 at 15:49UTC Have you tried downloading the file with a standard FTP client? Does that work? Make sure the FTP client is in active mode, as that's the default with Net::FTP as well. If it fails interactively with active mode, but succeeds with passive mode, you need to give the Passive option to the Net::FTP constructor. See also the Net::FTP manual page. Abigail[reply][d/l][select] Re^2: Bad file number by Anonymous Monk on J
Ago 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: if (!$ftp->get($ftp_FileList, $output_file_path."$ftp_FileList")) { $logger->error("Status: Can't Get File $ftp_FileList \n"); unlink($output_file_path.$ftp_FileList); next; }else {$logger->info("Update the cache file"); print CASHE_WRITE "$ftp_FileList\n"; $logger->info("Updated the cache file"); } $ftp->quit or die $logger->error("Couldn't quit ftp session\n"),exit; $logger->info("---------------------------Quiting FTP----------------------------\n"); http://www.perlmonks.org/?node_id=173858 close CASHE_WRITE || $logger->error("Can't close $cacheFile opened in write mode\n"); Thanks Debangana perl Debangana 5 posts since Apr 2009 Community Member 2Contributors 3Replies 4Views 7 YearsDiscussion Span 7 Years Ago Last Post by Debangana 0 Discussion Starter Debangana 7 Years Ago Hi I tried enabling the debug mode and here is what the code logs: Net::FTP=GLOB(0x40b6b868)<<< 226 Transfer complete. https://www.daniweb.com/programming/software-development/threads/184773/ftp-quit-fails-with-bad-file-number-error-for-some-servers 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 0 Comatose 290 7 Years Ago 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. 0 Discussion Starter Debangana 7 Years Ago Sorry for the late reply. Thanks for your
Search Username Password Remember Me? Register Lost Password? facebook google twitter rss Free Web Developer Tools Advanced Search Forum Programming Languages Perl Programming Bad File Number??? Thread: Bad File Number??? Share This Thread Tweet This + 1 this Post http://forums.devshed.com/perl-programming-6/bad-file-88197.html To Linkedin Subscribe to this Thread Subscribe to This Thread October 2nd, 2003,12:01 AM https://supportforums.cisco.com/discussion/10870661/cisco-archive-config-backup-problems #1 No Profile Picture Diyar View Profile View Forum Posts Visit Homepage Contributing User Devshed Newbie (0 - 499 posts) Join Date Sep 2003 Location Singapore Posts 54 Rep Power 14 Bad File Number??? Hi all. Help me interpret this error msg.. cos I still do not have any idea what the error is… I able ftp error to run my program but halfway, through it stop and error message appear: Code: Bad file number at main.pl line 179
Follow Us Instagram YouTube Facebook Twitter Google + LinkedIn Newsletter DirectoryNetwork InfrastructureWAN, Routing and Switching LAN, Switching and Routing Network Management Remote Access Optical Networking Getting Started with LANs IPv6 Integration and Transition EEM Scripting Other Subjects SecurityVPN Security Management Firewalling Intrusion Prevention Systems/IDS AAA, Identity and NAC Physical Security MARS Email Security Web Security Other Subjects Service ProvidersMetro MPLS Voice Over IP XR OS and Platforms Video Other Subjects Collaboration, Voice and VideoIP Telephony Video Over IP Jabber Clients Unified Communications Applications TelePresence Digital Media System Contact Center Conferencing UC Migrations Other Subjects Wireless - MobilitySecurity and Network Management Wireless IP Voice and Video Getting Started with Wireless WLCCA Other Subjects ServicesCisco ServiceGrid Connected Analytics Smart Call Home Smart Net Total Care Operations Exchange Mobile ApplicationsCisco Proximity Cisco Technical Support Online Tools and ResourcesCisco Bug Discussions Technical Documentation Ideas Cisco CLI Analyzer Support Community Help Data CenterApplication Centric Infrastructure Application Networking Intelligent Automation Server Networking Storage Networking Unified Computing Wide Area Application Services (WAAS) Other Subjects Small BusinessNetwork Storage Routers Security Surveillance Switches Voice and Conferencing Wireless Solutions and ArchitecturesBorderless Networks Collaboration Cisco User GroupsSeattle Cisco User Group (SEACUG) Silicon Valley Cisco User Group (SVCUG) Southern California Cisco User Group (SCCUG) Cisco Certifications Cisco.com Idea Center Cisco Cafe Expert CornerTop Contributors Leaderboards Cisco Live! Events Events Community CornerAwards & Recognition Behind the Scenes Feedback Forum Cisco Certifications Cisco Press Café Cisco On Demand Support & Downloads Community Resources Security Alerts Security Alerts News News Video Cisco Support YouTube Cisco YouTube Blogs Technical Documentation Cisco Products Products Services Services Solutions Solutions Global Support Numbers Cisco Support Community Directory Network Infrastructure WAN, Routing and Switching LAN, Switching and Routing Network Management Remote Access Optical Networking Getting Started with LANs IPv6 Integration and Transition EEM Scripting Other Subjects Security VPN Security Management Firewalling Intrusion Prevention Systems/IDS AAA, Ide