Gossamer Forum
Home : General : Perl Programming :

Testing Perl cgi-bins on command line

Quote Reply
Testing Perl cgi-bins on command line
In order to check why a Perl-based cgi-script doesn't work (and not having access to a WWW-server's log files), I thought of executing the script from the command line.

However, I don't know how to simulate form fields. Is there a way to run a cgi-script and have form variables set to values; all from the command line ?

Georg
Quote Reply
Re: Testing Perl cgi-bins on command line In reply to
If the script uses CGI.pm then it's really easy as you will be prompted for form fields to enter.

Since it most likely doesn't (as otherwise you wouldn't have posted the question), there's not a real easy way to simulate the input. It all depends on how the script looks for input, via GET or via POST method (or perhaps both). If it's GET, then you need to set an environment variable REQUEST_METHOD equal to GET, and QUERY_STRING equal to the query passed in. If it's post, you need to set REQUEST_METHOD = POST, CONTENT_LENGTH = length of the input, and pipe the input into STDIN. Not an easy task.. Better off looking for those log files.. Smile

Cheers,

Alex