#!/bin/csh -f

while (1)
set rawline = $<
set line = ($rawline)
if ("$line" =~ \#\!*) exit(0)
echo "$line" >>~/warnlog.txt
if ($1) then
  set from = `echo $line[3] | cut -d\( -f2 | cut -d: -f1 | cut -d\) -f1`
# additional stuff is a kludge to fix truncated names like "bagend.eng.umd.e":
  set fromtail=`echo $from | cut -d. -f4 | cut -c3`
  if ("$fromtail" == "") set from = `echo $from | cut -d. -f1`
  if ("$from" == "unix") set from = ""
  if ("$from" != "") set from = "@"$from
  mail $line[1]$from <~/warnmsg.txt
endif
if ($2) write $line[1] $line[2] <~/warnmsg.txt
end
