in reply to Port a script with STDIN/STDOUT to CGI?
#!/usr/bin/perl use CGI; my $cgi = CGI->new(); if ($cgi->request_method() eq 'POST') { if (my ($my_param) = $cgi->param('my_param')) { print($cgi->header('text/plain')); close(STDERR); open(STDERR, '>&', \*STDOUT); exec 'my_prog', $my_param; } } print($cgi->header('text/html')); print(<<'__EOI__'); <title>my_prog</title> <form method="POST"> <h1>my_prog</h1> <p>my_param: <input type="text" name="my_param"> </form> __EOI__ }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Port a script with STDIN/STDOUT to CGI?
by spickles (Scribe) on Sep 01, 2009 at 19:15 UTC |