|
Answer» I'm getting a "Bad file descriptor" error when I try and LIST the files on my FTP server. Server is *nix, trying to connect on my WinXP box I can connect and login just won't list any files. Tried 'ls' as well as 'dir' with same result.
Code: [Select]my $host="FTP.server.net"; my $DIRECTORY="/";
$ftp=Net::FTP->new($host,Debug=> 1,Passive=> 1,Timeout=>240) or $newerr=1; PUSH @ERRORS, "Can't ftp to $host: $!\n" if $newerr; myerr() if $newerr; print "Connected\n";
$ftp->login("user","PASS") or $newerr=1; print "Getting file list"; push @ERRORS, "Can't login to $host: $!\n" if $newerr; $ftp->quit if $newerr; myerr() if $newerr; print "Logged in\n";
$ftp->cwd($directory) or $newerr=1; push @ERRORS, "Can't cd $!\n" if $newerr; myerr() if $newerr; $ftp->quit if $newerr;
@files=$ftp->dir or $newerr=1; push @ERRORS, "Can't get file list $!\n" if $newerr; myerr() if $newerr; print "Got file list\n"; foreach(@files) { print "$_\n"; } $ftp->quit;
sub myerr { print "Error: \n"; print @ERRORS; exit 0; }
|