Unfortunately -f and -d won't work on an FTP server, so Net::FTP isn't going to help.
It should be possible, but you'll need to send the remote server 'pwd' and 'list' requests in order to figure out the directory structure yourself (which you should be able to do by just looking at the file permissions, and seeing it it's prefixed by a '^d' or not).
And whilst I know it's not perlish, I suggest taking a look at wget if you are trying to recurse through an ftp site.
HTH
--
It's not pessimism if there is a worse option, it's not paranoia when they are and it's not cynicism when you're right.
| [reply] |
Well not to do it all for you but try something like this, it makes a webpage that shows the contents of a FTP site with links that work:
#! /usr/bin/perl -w
use strict;
use Net::FTP;
my $ftp = Net::FTP->new("Address to ftp site);
print "Content-type: text/html\n\n";
print "<html><title>FTP Contents</title>";
print "<body bgcolor=black text=white link=lime vlink=wheat>";
if($ftp->login("Username", 'password')){
lister(0,"ftp://toplevel/");
}
else{
print "FTP: Failed to login";
}
$ftp->quit;
print "</body></html>";
#----subs----
sub lister{
my $lev = shift;
my $path = shift;
my @dirs;
my @files;
my @dirarray = $ftp->ls();
foreach my $item(@dirarray){
if($ftp->cwd($item)){
$ftp->cdup();
push @dirs,$item;
}
else{
push @files,$item;
}
}
my $buff="     " x $lev;
foreach my $dirs(@dirs){
print "<font color=yellow>$buff\|_ $dirs</font><br>";
$ftp->cwd($dirs);
lister($lev+1,$path."/".$dirs);
}
foreach my $file(@files){
print "<font color=lime>$buff\|_ <a href=\"$path/$file
+\">$file</a></font><br>";
}
$ftp->cdup();
}
Try looking at this seeing what I am doing. Basically, it checks the dir of a directory, splits the objects into directories and files, and recurses into the directories. Hope it helps.
Anyway, no drug, not even alcohol, causes the fundamental ills of society.
If we're looking for the source of our troubles, we shouldn't test people
for drugs, we should test them for stupidity, ignorance, greed and love of
power.
--P. J. O'Rourke | [reply] [d/l] |
Awesome This is exactly what i wanted... I learned alot thankz
| [reply] |
| [reply] |