2 #Autor : xiaoranzzz@myplace
3 #Date : 2008.08.07 06:31AM
5 my $appname="listlinks.pl";
6 my $appdesc="listlinks of URL, optionally run COMMANDS against it";
10 print "$appname v$appver\n\t- $appdesc\n","Usage:\n","\t";
11 print "$0 [options] URL commands";
14 print "\t-d\tDebug mode\n";
15 print "\t-n\tNo recursive mode\n";
16 print "\t-h\tDisplay this text\n";
20 my ($nr,$DEBUG,$url,@downloader);
23 if($arg eq "-h" || $arg eq "-H") {
37 push @downloader,$arg;
43 @lister=("wget","-v");
46 @lister=("wget","-q");
49 use File
::Temp qw
/tempfile/;
52 return unless($ftp_url);
54 my (undef,$fn) = tempfile
();
55 print STDERR
"Listing $ftp_url...\n";
56 if(system(@lister,"-O",$fn,$ftp_url) == 0) {
57 # print STDERR "\t[OK]\n";
64 if(m
#<a href="([^"]+)"#i) {
66 my $type= ($url =~ /[\/\\]$/) ?
"directory" : "file";
67 push @
{$result{$type}},$url;
76 return undef unless($url);
79 print STDERR
"#",join(" ",@downloader)," $url","\n";
81 return(system(@downloader,$url)==0);
92 my %result = listftp
($fdurl);
93 my @dirs = @
{$result{directory
}} if($result{directory
});
94 my @files = @
{$result{file
}} if($result{file
});