STDOUT:use Net::FTP; my $FtpHost = "ftp.ncbi.nih.gov"; my ($ftp, $user, $password); # the destination directory my $NewCwd = "/genomes/Bacteria"; # listing of the directories, and sorted listing my (@DirList, @sorted); print "Logging in to $FtpHost.\n"; print "Logging in now.\n"; my $ftp = Net::FTP->new($FtpHost); $user = "anonymous"; $password = "murcia\@home.de"; if( $ftp->login($user, $password) != 1 ){ die "Can't login to $FtpHost\n"; } print "Logged in.\n"; print "Logged in to $FtpHost.\n"; # the present working directory my $Pwd; # get the current working directory if ( ($Pwd = $ftp->pwd) eq "" ) { die "Can't get current directory\n"; } else { print "pwd = $Pwd\n"; } # changing pwd to $NewCwd and then log it $ftp->cwd($NewCwd) || die "Can't cwd to $NewCwd\n"; $Pwd = $ftp->pwd; print "cd $NewCwd\n"; print "pwd = $Pwd\n"; # Returns a reference to a list of contents of the directory print "Retrieving entries in $Pwd\n"; if ((@DirList = $ftp->ls("*")) eq "") { die "Nothing found in the directory $NewCwd\n"; } print "@DirList\n";
Logging in to ftp.ncbi.nih.gov. Logging in now. Logged in. Logged in to ftp.ncbi.nih.gov. pwd = / cd /genomes/Bacteria pwd = /genomes/Bacteria Retrieving entries in /genomes/Bacteria EOF
I tested this script on different computers with Linux OS with different perl versions (5.8.x).
$ftp->dir() does give also no results ...
And I tested different server e.g "ftp.suse.com"In reply to Net::ftp listing problem by Murcia
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |