#!/usr/bin/perl -Tw # # This is John Chambers' CGI script to take the output of the saying # command and deliver it as a web page. Look for the Sayings file for # the data used by these programs. $| = 1; $inHTML = 1; $V = 1; use CGI; use CGI::Carp 'fatalsToBrowser'; use diagnostics; $ENV{PATH} = "/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin"; print "Content-type: text/html\n\n"; print "
\n"; print "\n";
$cmd .= " $1";
}
}
print "Cmd: \"$cmd\"
\n" if $V>1;
@txt = `$cmd`;
for $line (@txt) {
($pfx,$msg) = ($line =~ /^(\|*)(.*)\s*$/);
if ($pfx eq '|') { # HTML?
if (!$inHTML) {
print "";
$inHTML = 1;
}
} else { # Plain text.
if ($inHTML) {
print "
";
$inHTML = 0;
}
}
if ($inHTML) {
$msg =~ s/^\s*//;
$msg = "" unless $msg;
}
print "$msg\n";
}
print "\n";
exit 0;