#!/usr/local/bin/perl # # www.scan.email # # Run www.scan.email and send results to the appropriate people. # Send personal messages for personal web references. # ### ### Configuration ### $ScanOutput = "/tmp/www.scan.out"; $Host = "www.ao.com"; $WebAuthors = "webmaster regan"; # People who get global messages ### ### Execution ### # Run the checking program unlink($ScanOutput); system("/usr/local/bin/www.scan >$ScanOutput"); if ($? == 0) { print "www.scan ran without errors\n"; print "www.scan output is in $ScanOutput\n"; exit 0; } # Find the problems. open(DATA, "<$ScanOutput") || die "Cannot open $ScanOutput"; $| = 1; # Force flushing $previous = ""; while () { chop; next if (/Checking file/); if (/referenced from/) { save($previous, $_); } elsif (/Under construction/) { save("", $_); } elsif (/Missing file:/ || /Missing name:/ || /Referenced from/) { $previous = $_; } } # Mail to the appropriate individuals. while (($key, $value) = each %Msgs) { if ($key !~ /^~/) { print "Sending mail for global failures to $WebAuthors\n"; open(MAIL, "|mail -s \"Global web check failures found\" $WebAuthors") || die "Cannot open mail"; print MAIL "The following messages are being sent to people who maintain\n"; print MAIL "the company's web pages. Please update things which you can\n"; print MAIL "and hopefully someone else will get the others.\n\n"; print MAIL "To see the full run of the checking program, look at $ScanOutput.\n"; print MAIL "You can put problem URLs in ~/public_html/www.scan.exceptions\n"; print MAIL "so that they will never be checked, and thus never draw\n"; print MAIL "error messages.\n\n\n"; } else { $author = $key; $author =~ s/^~//; print "Sending mail for home pages to $author\n"; open(MAIL, "|mail -s \"Home page web check failures found\" $author") || die "Cannot open mail"; print MAIL "You have some linkage errors in your personal home page.\n"; print MAIL "The following errors have been found, which means that visitors\n"; print MAIL "may be getting confused.\n\n"; print MAIL "To see the full run of the checking program, look at $ScanOutput.\n"; print MAIL "You can put problem URLs in ~/public_html/www.scan.exceptions\n"; print MAIL "so that they will never be checked, and thus never draw\n"; print MAIL "error messages.\n\n\n"; } print MAIL "$value\n\n"; close MAIL; } ### ### save ### ### Save a line with an appropriate user. ### sub save { local($line1, $line2) = @_; $list = "normal"; if ($line2 =~ m#$Host/~#) { $list = $line2; $list =~ s#^.*$Host/##; $list =~ s#/.*##; } elsif ($line2 =~ m#/cornvalley#) { $list = "~regan"; } $Msgs{$list} .= "$line1\n" if ($line1 ne ""); $Msgs{$list} .= "$line2\n" if ($line2 ne ""); print "Added $line1 $line2 to $list\n"; # Debug output }