3 # Author: Daniel Stenberg <Daniel.Stenberg@sth.frontec.se>
7 # This is just meant as an example of why we wrote curl in the first place.
8 # Quick n' easy scripting use.
17 if($dir eq "" || $target eq "") {
18 print "Usage: <URL> <dir> [max depth level] \n";
19 print " End the URL with a slash if a directory is specified, please\n";
23 if(($maxdepth ne "") && ($maxdepth == 0)) {
24 # reached maximum depth, die
25 print "Reached maximum recursive depth level ($maxdepth), exiting...\n";
30 @all = `curl -s $dir`;
33 print "Got the main $dir dir\n";
38 chop; # cut off newline
39 @linep= split(" ", $_);
41 $name = $linep[$#linep];
43 $firstletter=substr($linep[0], 0, 1);
45 if($firstletter eq "d") {
46 # this is a subdir, recurse
47 # if not . or .. of course
49 if(($name eq ".") || ($name eq "..")) {
52 print "Recursing for dir $dir$name in target $target/$name\n";
54 $nextdepth=$maxdepth-1;
55 print `$0 $dir$name/ $target/$name $nextdepth`;
57 elsif($firstletter eq "-") {
58 # this is a file, get it
59 # oh, make sure the target dir exists first
64 print "Getting file $dir$name in target $target/$name\n";
65 print `curl -s $dir$name >$target/$name`;