in reply to Recursion Over FTP
#! /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(); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Recursion Over FTP
by jmaya (Acolyte) on Oct 03, 2002 at 22:27 UTC |