tohann has asked for the wisdom of the Perl Monks concerning the following question:
Each subsequent file will fail until the FTP connection is terminated and then reopened. At that point the first one will successfully transfer and the rest will fail. Here is the relevant code snippet:Connecting to server(web1) as xxxxxx... Net::FTP: Net::FTP(2.65) Net::FTP: Exporter(5.566) Net::FTP: Net::Cmd(2.21) Net::FTP: IO::Socket::INET(1.26) Net::FTP: IO::Socket(1.27) Net::FTP: IO::Handle(1.21) Net::FTP=GLOB(0x8389760)<<< 220 "Access is being monitored - Unauthori +zed access is prohibited" Connected... Net::FTP=GLOB(0x8389760)>>> user xxxxxx Net::FTP=GLOB(0x8389760)<<< 331 Please specify the password. Net::FTP=GLOB(0x8389760)>>> PASS .... Net::FTP=GLOB(0x8389760)<<< 230 Login successful. Have fun. Logged in... Net::FTP=GLOB(0x8389760)>>> CWD /aaaa/bbbbbbb/ccc/ Net::FTP=GLOB(0x8389760)<<< 250 Directory successfully changed. Reading /aaaa/bbbbbbb/ccc/ Net::FTP=GLOB(0x8389760)>>> PASV Net::FTP=GLOB(0x8389760)<<< 227 Entering Passive Mode (999,999,999,99, +999,26) Net::FTP=GLOB(0x8389760)>>> LIST /aaaa/bbbbbbb/ccc/access_log.0107 Net::FTP=GLOB(0x8389760)<<< 150 Here comes the directory listing. Net::FTP=GLOB(0x8389760)<<< 226 Directory send OK. Net::FTP=GLOB(0x8389760)>>> PASV Net::FTP=GLOB(0x8389760)<<< 227 Entering Passive Mode (999,999,999,99, +999,53) Net::FTP=GLOB(0x8389760)>>> RETR /aaaa/bbbbbbb/ccc/access_log.0107 Net::FTP=GLOB(0x8389760)<<< 150 Opening BINARY mode data connection fo +r /aaaa/bbbbbbb/ccc/access_log.0107 (1073993 bytes). Net::FTP=GLOB(0x8389760)<<< 226 File send OK. getting /aaaa/bbbbbbb/ccc/access_log.0107 to /wwww/xxxxxx/yyyyyy/zz +z/access_log.0107 (1073993 bytes)...done. Net::FTP=GLOB(0x8389760)>>> PASV Net::FTP=GLOB(0x8389760)<<< 227 Entering Passive Mode (999,999,999,99, +999,73) Net::FTP=GLOB(0x8389760)>>> LIST /aaaa/bbbbbbb/ccc/agent_log.0107 Net::FTP=GLOB(0x8389760)<<< 150 Here comes the directory listing. Net::FTP=GLOB(0x8389760)<<< 226 Directory send OK. Net::FTP=GLOB(0x8389760)>>> PASV Net::FTP=GLOB(0x8389760)<<< 227 Entering Passive Mode (999,999,999,99, +999,78) Net::FTP=GLOB(0x8389760)>>> RETR /aaaa/bbbbbbb/ccc/agent_log.0107 Net::FTP=GLOB(0x8389760)<<< 150 Opening BINARY mode data connection fo +r /aaaa/bbbbbbb/ccc/agent_log.0107 (540485 bytes). Net::FTP=GLOB(0x8389760)<<< 426 Failure writing network stream. Unable to close datastream at FTPWebLogs.pl line 62 getting /aaaa/bbbbbbb/ccc/agent_log.0107 to /wwww/xxxxxx/yyyyyy/zzz +/agent_log.0107 (540485 bytes)... ERROR::426:Opening BINARY mode data connection for /aaaa/bbbbbbb/ccc/a +gent_log.0107 (540485 bytes). Failure writing network stream. ... more failures from more log files ...
Any ideas why the network stream is failing?foreach my $serverDir (split(',', $serverDirs)) { addMessage("Connecting to server(" . $props{'ftp_server'} . ") as " + . $props{'ftp_username'} . "...\n"); $ftp = Net::FTP->new($props{'ftp_server'}, Debug => $isDebug, Passi +ve => 1) or error("Cannot connect to " . $props{'ftp_server'} . ": $@ +"); addMessage("Connected...\n"); $ftp->login($props{'ftp_username'}, $props{'ftp_password'}) or erro +r($props{'ftp_username'} . " cannot login to " . $props{'ftp_server'} + . ": " . $ftp->message, 1); addMessage("Logged in...\n"); $ftp->cwd("$baseDir$serverDir"); addMessage("Reading $baseDir$serverDir\n"); foreach my $file (split(',', $props{'files_to_move'})) { $file .= ".$formattedDate"; my $fileSize = $ftp->size("$baseDir$serverDir$file"); addMessage(" getting $baseDir$serverDir$file to $destDir$serve +rDir$file ($fileSize bytes)..."); if ($fileSize > 0) { $ftp->get("$baseDir$serverDir$file", "$destDir$serverDir$file +") or error($ftp->code . ":" . $ftp->message, 0); addMessage("done.\n"); } else { addMessage("\n Not getting file because it's empty, but +creating an empty file anyway.\n"); `touch $destDir$serverDir$file`; } } $ftp->quit(); undef $ftp; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: FTP log files fails with a 426 error code
by runrig (Abbot) on Apr 13, 2016 at 18:43 UTC | |
|
Re: FTP log files fails with a 426 error code
by tohann (Sexton) on Jan 10, 2005 at 14:16 UTC |