On Wed, 6 Sep 2000, erich oliphant wrote:

> I am replacing a CGI shell script with a modperl script.  At one point in 
> the shell script subprogram is called.  The HTML form that calls the script 
> calls it via a POST.  As such the params are available via STDIN.  The 
> subprogram call (which I can't eliminate yet) expects to see the form 
> params.  However when I call it from the perl script STDIN is empty.  I have 
> tried backticks and the open call (which are supposed to inherit STDIN) to 
> no avail.

STDIN cannot be passed to a subprocess, because STDIN is not stdin under
mod_perl.  that is, it's not a file descriptor, it's just a Perl glob,
that's tie-d to the Apache request_rec + api.  one solution would be to do
switch the POST to a GET:

local $ENV{PATH} = '/home/dougm/bin';

my $r = shift;

$r->send_http_header;

local $ENV{GATEWAY_INTERFACE} = 'CGI/1.1'; #hmm, shouldn't need todo this

local $ENV{QUERY_STRING} = $r->content;
local $ENV{REQUEST_METHOD} = 'GET';
local $ENV{CONTENT_LENGTH} = 0;

print `cgi-dump`;

where cgi-dump is:
#!/usr/local/bin/perl

use CGI ();

my $q = CGI->new;

print $q->as_string;

works just fine:

% POST http://localhost:8529/perl/post.pl
Please enter content (application/x-www-form-urlencoded) to be POSTed:
one=1
<UL>
<LI><STRONG>one</STRONG>
<UL>
<LI>1<BR>

</UL>
</UL>


Reply via email to