#!/usr/bin/perl 

use Net::SMTP;

my ($smtp);


$pwd = `pwd`;
chomp($pwd);
$pwd =~ s/.*\///;


$file = "/var/www/html/testtau/index.html";

@theFile = `grep -v HERE $file`;

open (OUTPUT, ">$file");

print OUTPUT @theFile;

print OUTPUT "<tr><td><a href=\"$pwd\">" . $pwd . "</a></td>\n";



@errors = `grep -H "Failure: Encountered" *.log`;

@runlog = `cat run.log`;

$ret = $? >> 8;


if (@errors >= 1) {
    print "found an error!\n";
    print OUTPUT "<td bgcolor=#FF0000>";

    foreach $line (@errors) {
	$log = $line;
	$log =~ s/:.*//;
	print OUTPUT "<a href=\"$pwd/$log\">$line</a><br>";
    }

    print OUTPUT "</td>\n";


    
    print @runlog;
    
# don't send email, we have another way now
#     my $from = "Tau Team <amorris\@cs.uoregon.edu>\n";
#     my $to = "Alan Morris <amorris\@cs.uoregon.edu>\n";
#     $message = "Subject: Tau Regression failure\n\nRegression test failed\nSee http://proton.nic.uoregon.edu/testtau for more details.\n\nRun log:\n";
#     $smtp = Net::SMTP->new('127.0.0.1', Debug => 0);
#     $smtp->mail( $from );
#     $smtp->to( "amorris\@cs.uoregon.edu" ) ;
#     $smtp->data();
#     $smtp->datasend("From: $from");
#     $smtp->datasend("To: $to");
#     $smtp->datasend($message);
#     $smtp->datasend(@errors);
#     $smtp->datasend(@runlog);
#     $smtp->dataend();
#     $smtp->quit;



} else {
    print OUTPUT "<td bgcolor=#64FF64>OK!</td>\n";

}


    
print OUTPUT "</tr>\n\n <!-- HERE --></table></html>";

close (OUTPUT)
