- 论坛徽章:
- 0
|
- #!c:/perl/bin/perl.exe -w
- use Net::FTP;
- use strict;
- my $server='202.96.64.144';
- my $user = 'anonymous';
- my $pw = 'anonymous';
- my $ftp = Net::FTP->new($server) ;
- $ftp->login($user,$pw) ;
- #print "login ok! starting list files on $server....\n";
- &list("/pub");
- $ftp->quit;
- sub list()
- {
- my $current = $_[0];
- my @subdirs;
-
- $ftp->cwd($current);
- my @allfiles = $ftp->ls();
-
- foreach (@allfiles){
- if(&find_type($_) eq "d"){
- push @subdirs,$_;
- }
- else{
- print $current."/$_\n";
- }
- }
-
- foreach (@subdirs){
-
- &list($current . "/" . $_);
- }
- }
- sub find_type{
- my $path = shift;
- my $pwd = $ftp->pwd;
- my $type = '-';
- if ($ftp->cwd($path)) {
- $ftp->cwd ($pwd);
- $type = 'd';
- }
- return $type;
- }
复制代码
每次运行都出现
getsockname() on closed socket
linux没这问题 |
|