Hallo, dies ist ein Test.
PWD: /www/data-lst1/unixsoft/unixsoft/kaempfer/.public_html
Running in File Mode
Relative path: ./../../../../../server/etc/scripts/db/mkwwwindex
Real path: /www/server/etc/scripts/db/mkwwwindex
Zurück
#!/usr/bin/perl # MkWWWlist version 0.1 # Usage: mkwwwindex [-rltbg] [-R rootdir] [-h host] dir # -r means recursively do subdirectories # -l means don't follow symbolic links # -t include all text files # -b include binary and text files # -g full text grep search of files rather than title only # dir is starting directory relative to root (if empty use root) # This program produces a file consisting of lines of the form # title<tab>url\n or title<tab>url<tab>path2file\n # if the -g option is used. It assumes that the only address translation # from a URL to the file path is prepending the root directory. # This program has been placed in the public domain by its author # John Franks # You must edit the following fields filling in you root directory and host. $host="www2.informatik.hu-berlin.de"; $rootdir="/www/server/data/WWW"; $stub = ''; ########################################################################## require "getopts.pl"; &Getopts( "rltbgR:h:"); $opt_t |= $opt_b; #Option -b implies option -t $host= $opt_h ? $opt_h : $host; $rootdir= $opt_R ? $opt_R : $rootdir; $startdir=$ARGV[0]; if ($startdir =~ /\/~/) { $stub = $startdir; @nam = split (/\//, $stub); ($pwn, $pwp, $pwu, $pwg, $pwq, $pwc, $pwe, $dir, $pws) = getpwnam(substr($nam[1], 1)); $nam[1] = $dir . "/.public_html"; $rootdir = substr( join("/", @nam), 1); $startdir = ''; } &dodir($startdir); sub dodir { local($dir) = @_; local($path) = $rootdir.$dir; local($file); if (!opendir( DIR, $path)) { print STDERR "Can't open $path\n"; return; } local( @filenames) = readdir(DIR); closedir(DIR); foreach $file (@filenames) { next if ($file =~ /^\./); next if ($opt_l && (-l $file)); if ( $file =~ /\.html$/) { &do_file( $dir, $file, "h"); } elsif ( $opt_t && (-T "$path/$file")) { &do_file( $dir, $file, "t"); } elsif ( $opt_b && (-B "$path/$file") && !(-d "$path/$file")) { &do_file( $dir, $file, "b"); } $linkname = readlink("$path/$file"); if ( $linkname =~ '^\.') { print STDERR "path: $path/$file\n"; print STDERR "linkname: $linkname\n"; $linkname = "punktlink"; print STDERR "linkname: $linkname\n"; } else { &dodir( "$dir/$file") if (( -d "$path/$file") && $opt_r && ( "$file" !~ /te?mp/ ) ); } } } sub do_file { local( $dir, $file, $type) = @_; local( $filepath) = $rootdir.$dir."/".$file; if ( $type eq "b" ) { $title = "Binary file: $file"; } elsif ( $type =~ /[ht]/ ) { if (!open( TEXT_FILE, $filepath)) { print STDERR "Can't open $filepath\n"; return; } local( $line) = ""; local( $l ); local( $linenum) = 1; $title = "Text file: $file"; $foundtitle = 0; while ( $l = <TEXT_FILE>) { last if ($linenum > 5); $linenum++; chop ($l); $line .= " " . $l; } if ($line =~ s/^.*<tItle>//i ) { $line =~ s!</tiTle>.*$!!i; $title = $line; $title =~ s/^\s*//; $title =~ s/\s*$//; $title =~ s/\t/ /; $foundtitle = 1; } close( TEXT_FILE); } if ( ($type =~ /[bt]/) || $foundtitle) { if ( $opt_g ) { printf( "%s\thttp://%s%s/%s\t%s\n", $title, $host, $stub.$dir, $file, $filepath); } else { printf( "%s\thttp://%s%s/%s\n", $title, $host, $stub.$dir, $file); } } }