in reply to NET::FTP - Unexpected EOF on command channel

You may have to wrap eval { } around the calls to Net::FTP. My information is only 2nd-hand but I've heard that Net::FTP is horrid at error reporting and will die suddenly if it feels like it.

        - tye (but my friends call me "Tye")

Replies are listed 'Best First'.
Re: (tye)Re: NET::FTP - Unexpected EOF on command channel
by lestrrat (Deacon) on May 15, 2001 at 21:20 UTC

    Not to discredit its author(s), but yes, I feel the same way about Net::FTP. It's a really neat tool to do trivial FTP, but when it comes to codes which must handle errors in some elaborate fashion, then you don't get much.

    For anything like that, you just have to write your own version. You may even want to copy Net::FTP and Net::Cmd and hack its internals.

    .... and yes, I have done the above to get more useful data. It's not exactly pleasant :-)

    Once again, though, it's a neat tool. Just not what you want to use for this

      Oh... arse. Thanks for your help.

      It runs every half-hour so if it fails the first time it should pick up the rest later, not perfect though...

        Found out that if an EOF error happens the command returns 0, $ftp->code() returns 0, and $ftp->message() returns "", so here's a way around it which I'm posting if it'll help anyone else...

        It returns 1000 on an EOF and the routine that calls it thinks it's an unrecoverable FTP error as it's above 500 and quits.

        Cheers.

        sub ftp_move() { my $file=$_[0]; my $exempt=-1; my $code; $exempt=$_[0] if $_[0]; if(-e $rvf_incoming.$file.".done") { &write_log("+ [$file] already exists in incoming direc +tory, skipping",0); $files_skipped++; return 0; } &write_log("+ [$file] interesting name, moving to incoming dir +ectory.",0); if($ftp->get($file,$rvf_incoming.$file)) { # Don't bother about errors, may not have permission t +o delete. ### TEMPORARY ### $ftp->delete($file); open(DONE,">".$rvf_incoming.$file.".done"); close(DONE); $files_moved++; return 0; } $code=$ftp->code(); if($code==0 && $@ eq "") { &write_log("! error, unexpected EOF on command channel +",0); return 1000; } if($code>=400) { if($code!=$exempt) { &write_log("| [$file] error moving from FTP si +te - ".$code." $@",0); $files_error++; } return $code; } return 0; }