#!/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 "Saying of the Day\n"; print "\n"; ($cwd = `/bin/pwd`) =~ m/(.*)[\r\s]+$/; $cwd = $1; print "CWD: \"$cwd\"
\n" if $V>1; $cmd = "$cwd/bin/saying"; if ($n = $ENV{'PATH_INFO'}) { $n =~ s/\D+//g; if ($n =~ m/(\d+)/) { print "Saying $1:

\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;