in reply to Testing out a CGI script using the command line
However, if this is not possible for some reason, you can write a simple wrapper which emulates the relevant CGI Environment Variables.
This is an (untested) example for emulating the GET environment, which should work for non-perl CGI's as well:
print &get_response("/path/to/cgi.pl", "test=true"); sub get_response { my ($cgi, $CMD) = shift; ## prepare proper (CGI) environment $ENV{QUERY_STRING} = $CMD; $ENV{REQUEST_METHOD} = 'GET'; $ENV{GATEWAY_INTERFACE} = 'CGI/1.1'; # add more as needed open(CGI, "$cgi |") or die "Can't exec $cgi, $!"; local $/ = undef; my $res = <CGI>; close(CGI) or die "Error running $cgi, $!"; return $res; }
--
Cheers, Joe
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Testing out a CGI script using the command line
by racer_x (Sexton) on Oct 09, 2002 at 15:43 UTC |