#! /usr/local/bin/perl ################################################################ # bot.pl Compiles data on VOH # Copyright 1995 Matthew J. Walker and UCLA. All rights reserved # withing boundries of GNU Public license for Perl. ################################################################ ## Some setup require "ctime.pl" ; $voh_root = "/net/etc/httpd/htdocs/uclavoh" ; $date = `date`; chop($date); ## Get the configuration info &GetConf ; open(LOG, ">$voh_root/docs/voh_questions.html") || (&Failure(3)) ; print LOG "

$date


" ; ## Open up the VOH area and get all the directories that begin with ## a number. opendir(CLASSES, "$voh_root") || (&Failure(1)) ; @classes = (grep(/^[1-9].*$/, readdir(CLASSES))); foreach $class (sort @classes) { ## For each class directory check the questions subdirectory for ## files. $date_of_oldest = "--" ; opendir(CLASSQ, "$voh_root/$class/questions/") || next ; @questions = sort (grep(!/^\.\.?$/, readdir(CLASSQ))); $number_of_questions = @questions ; unless ($number_of_questions == 0) { ## If there is an unanswered question, decode its date from its ## name. $date_of_oldest = &ctime($questions[0]); ###################### # Print Log File entry print LOG <<"EOL";

$class

Number of Unanswered Questions: $number_of_questions
Date of Oldest Question: $date_of_oldest
EOL ###################### ## Now send mail to the instructor unless (($email{$class} eq "no") || ($email{$class} eq "")) { #### &MailProf ; } } closedir CLASSQ; } close LOG; closedir CLASSES; ################################################################### ### GetConf ### Checks configuration file, and loads info into @conf. sub GetConf { open(CONF, "$voh_root/conf/voh.conf") || (&Failure(3)) ; while () { chop; next if /^#/ ; @conf = split(/,/, $_) ; ($lecture,$public,$confidential,$email) = @conf ; $email{$lecture} = $email; } close(CONF); } ### ### MailProf ### Send Email to the Profs about their questions. sub MailProf { open(MAIL, "|/usr/ucb/mail -s Questions-$class $email{$class}") || (&Failure(4)); print MAIL <<"EOM" ; Hello, This is automated output from VOH for $class: As of $date, you have: Number of Unanswered Questions: $number_of_questions Date of Oldest Question: $date_of_oldest Thank you, VOH Administration EOM close MAIL ; } ### # Failure # $error_text provides context sensitive error messages. All # script failures are caught and error messages generated. No # circumstance should allow a server error. sub Failure { local ($error, $html, $reason) = @_ ; FAILURE: { $error_text1 ="Cannot open voh directory" ; $error_text2 ="Cannot open class directory" ; $error_text3 ="Cannot open file" ; $error_text4 ="Cannot open mail" ; ($error == 1) && ($reason = $error_text1, last FAILURE); ($error == 2) && ($reason = $error_text2, last FAILURE); ($error == 3) && ($reason = $error_text3, last FAILURE); ($error == 4) && ($reason = $error_text4, last FAILURE); $reason = "Unknown error!" ; } print <<"EOF"; Failure: $reason Root_path: $voh_root Class: $class Classdir: $voh_root$class/questions/ EOF exit ; } # End all..... # Copyright Matthew J. Walker and UCLA 1995. All rights reserved.