- 论坛徽章:
- 0
|
print "*********************************************************\n";
print " FTP Find Tool\n";
print " Build by YangKang \n";
print "*********************************************************\n";
$ARGC=@ARGV;
if ($ARGC!=1) {
print "\n Usage: $0 ftpListFile\n";
exit;
}
use Net::FTP;
#use Strict;
use Socket;
my $ftpfile=$ARGV[0];
use Net::FTP;
sub find_type
{
my $path = shift;
my $a=substr($path,0,1);
return $a;
}
##########################################################
sub list
{
my $current = $_[0];
my @subdirs;
$current=substr($current,1);
print "$current \n";
$ftp->cwd($current);
my @dir=$ftp->dir($current);
print "\n", "-" x 70, "\n";
print "@dir\n";
foreach(@dir)
{
my $path=$ftp->pwd();
print "$_\n";
my $filetype=&find_type($_);
#print "$filetype\n";
$filename=substr($_,55);
#print "$filename\n";
if(&find_type($_) eq "d"
{
if($filename ne "."
{
if($filename ne ".."
{
$currentpath=$path . "/".$filename;
#print "$currentpath\n";
push @subdirs,$currentpath;
}
}
}
else
{
print $path."/$filename\n";
}
}
foreach (@subdirs)
{
#print "$_\n";
&list($_);
}
}
#read from file
open(USERFILE,$ftpfile)||die("Can't open the user's list!\n"
@data=<USERFILE>;
foreach(@data)
{
my @a=split /\s+/,$_;
$address=shift(@a);
$port=shift(@a);
$username=shift(@a);
$password=shift(@a);
print "Testing on $addressport usernameusername;passpassword ...\n";
$ftp=Net::FTP->new($address,Port => $port);
die "couldn't connect!\n" unless $ftp;
$ftp->login($username,$password);
if($ftp->cwd('/'))
{
print "FTP Serveraddress can be connected now!\n";
&list('/');
}
else
{
print "FTP Serveraddress cann't be connected now!\n";
}
$ftp->quit();
}
close (USERFILE);
exit(0); |
|