develooper Front page | perl.beginners | Postings from December 2002

Re: Simulating the query string from the command line

Thread Previous | Thread Next
Chander Ganesan
December 25, 2002 09:58
Re: Simulating the query string from the command line
Message ID:
I generally do the following:

1.  Create a shell script that executes a "set" (which prints out the
environment) and redirects it to a file.  That allows you to then create a
shell script which makes your environment *exactly* match the environment
set by the web server when you do a query.

2.  Redirect the standard input using 'cat' to a file (now you've captured
standard input to the script).

3.  echo the arguments into a file.

Now you've got a script which basically captures all the data that the
webserver might pass to it.  Now install it on your webserver as a
drop-in replacement for your script.  Then call it (as you would call
your script).  Now you've captured all the data that gets passed into
the script.  You can then pass this into your app for testing from the

Best of luck.


> Is there any way to feed a query string to a perl script from the
> command line?  I have some scripts that run well under IIS, but not on
> the Unix server where I will be porsting them when they go live.  I've
> checked the obvious things-- it has the proper #!/usr/bin/perl-w header,
> it addresses only files in the same folder, so should not have any path
> delimiter issues.  The newlines have all been striped of CRs.
> What I would like to do over telnet is to feed the app a query line, as
> if from a browser, and receive the output that would be sent.  Is there
> any way to prime STDIN and the ENV{'CONTENT_LENGTH'} so that my app
> behaves as it would were the input to be submitted by a POST request?

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About