[lug-nuts] Web Site Inventory

From: Lavender, Brian E SPK (BLavender@spk.usace.army.mil)
Date: Mon Dec 13 1999 - 15:22:40 PST


I thought I would share this PERL script with everyone.

It produces an html page showing all the html pages under a specified
directory. It produces an output html file called site.html in the base
directory. If you already have a file called site.html in your base
directory, it will die and warn you to change the name or to delete it.
Plus, all the inventoried files are made into hypertext links, so you can
select the link and visit the page along with a line number before the link.
It's useful for getting an inventory of your site.

Here's how to run the script:

chmod u+x file_find.pl
Modify the path to your perl
Change $base_url and $base_dir to match your setup.
./file_find.pl

Have fun

brian

#!/usr/local/bin/perl

# Configuration Variables
# Change these variables to match your web server's configuration

$base_url = "http://www.spk.usace.army.mil";
$base_dir = "/export/home/blavender";
$count = 1;

use File::Find;

if (! -f "$base_dir/site.html") {
  open (OUTFILE , ">$base_dir/site.html");
} else {
  die "$base_dir/site.html already exists.\n Remove or move it before
running this\n";
}

print OUTFILE << "__END__";
<html>
<head>
<title>Site Mapa</title>
<body>
<h1>$base_url Site Map</h1>
<PRE>
__END__

finddepth(\&wanted, $base_dir);

print OUTFILE << "__END__";
</PRE>
<P>
Originally developed by: <br>
<address>
<a href="mailto:blavender\@spk.usace.army.mil">Brian Lavender</a>
</address>
</html>
__END__

sub wanted {

  if (/\.html$/) {
    $temp = $File::Find::name;
    $temp =~ s/\Q$base_dir//;
    printf OUTFILE ("%5d",$count);
    print OUTFILE qq{ <A HREF="},$base_url,$temp, qq{">},$temp,"</A>\n";
    if ($count % 5 == 0) { print OUTFILE "\n"};
    $count++;
  }

}

--
Brian E. Lavender 
Army Corps of Engineers
(916) 557-6623
Sacramento, CA 
****************************************************************************
* To UNSUBSCRIBE from the list, send a message with "unsubscribe lug-nuts"
* in the message body to majordomo@saclug.org. Please direct other
* questions, comments, or problems to lug-nuts-owner@saclug.org.



This archive was generated by hypermail 2b29 : Fri Feb 25 2000 - 14:29:09 PST