HTML Spell Check
In this example, we do an HTML spell check using the =spelling_errors() script macro.
spelling_errors(site, SITE) init status =piktstatus level =piktlevel task "Report spelling errors in html files" input proc "for f in `find =httpd_doc_root/(site) -name \\*.htm\\* -print`; do echo $f; /usr/local/bin/spell_check.pl -d =objdir/(SITE)Dictionary.obj -f $f; done" begin set #havewords = #false() rule set #isword = #false() rule // determine if file or word if $left($inlin, 1) eq "/" set $file = $inlin =chomp($file, $newline()) #ifdef debug output "file: $file" #endifdef else set $word = $inlin =chomp($word, $newline()) set #isword = #true() #ifdef debug output "word: $word" #endifdef fi rule // bypass one-, two-, and three-letter words if #length($word) <= 3 next fi rule // if word, output file and word if #isword output mail "$file: $word" =incr(#counts[$word]) set #havewords = #true() fi end if #havewords output mail =newline foreach #keys($w, #counts) output mail $w endforeach output mail =newline output mail "review, add to dictionary_objects.cfg, then do: piktc -iv +O (SITE)Dictionary +H (site)web" fi
In the =spelling_errors() script macro, note how it uses a Perl script, spell_check.pl, for its input.
We might invoke the =spelling_errors() macro in our alarms.cfg (or one of its #include files) file thusly:
/////////////////////////////////////////////////////////////////////////////// SpellingErrorsPIKT =spelling_errors(pikt, PIKT) /////////////////////////////////////////////////////////////////////////////// SpellingErrorsEMC =spelling_errors(emc, EMC) ///////////////////////////////////////////////////////////////////////////////
The ReportPIKTSpellingErrors script might send an alert message like the following:
PIKT ALERT Mon Jul 26 20:49:19 2004 calgary INFO: SpellingErrorsPIKT Report spelling errors in html files spellng mesage review, add to dictionary_objects.cfg, then do: piktc -iv +O PIKTDictionary +H piktweb
This is just one program example. You could add rules, or write new scripts, for example to: automatically update certain web pages, report HTML coding errors, report broken links, etc.
For more examples, see Samples.