#!/usr/bin/perl -w use CGI; my $cgi = new CGI; print $cgi->header; my $message = $cgi->param('message'); my $figlet = ""; if ($message) { chdir "figlet/figlet22"; my $figoutput; # This next obscure line of code actually forks into two processes. # The open(-|) creates a pipe to another process that we can read from. # The child does the "exec", and never returns. The advantage is # that exec() doesn't use a shell, it just passes $message directly # to the figlet program; therefore, there is no "escape to the shell" issue. open(FIG,"-|") or exec("./figlet", $message); while (my $line=) { $figoutput .= $line; } close FIG; $figlet = "
$figoutput
\n"; } print <<"END_HTML"; cgi figlet three

cgi figlet three

This version uses a safer system call which traps all characters.
What is your message?
$figlet
END_HTML