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

Re: Simulating the query string from the command line

Thread Previous
From:
R. Joseph Newton
Date:
December 25, 2002 15:15
Subject:
Re: Simulating the query string from the command line
Message ID:
3E0A3C64.96335FDD@efn.org
Thanks Todd,

I guess I just needed to know it could be done.  I'm not eager to take on the overhead of a new package right now--see my response to Randal:  "Re: Fw: HTTP Requests" [Mon, 23 Dec 2002 20:29:32 -0800], but knowiong it could be done led me to this formualation:

sub ParseQueryLine {
  if ($ENV{'CONTENT_LENGTH'} and $ENV{'CONTENT_LENGTH'} ne "default") {
    read(STDIN, $quer, $ENV{'CONTENT_LENGTH'});
  } else {
    $quer = join(" ", @ARGV);
  }
  @pairs = split(/&/, $quer);

which works like a charm.

Happy Coding,

Joseph

Todd Wade wrote:

> "R. Joseph Newton" <rjnewton@efn.org> wrote in message
> news:3E08F165.42BB74F4@efn.org...
> > Hi,
> >
> > 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?
> >
> CGI.pm has this functionality built in. Pass a query string as an argument
> to the script:
>
> ./mycgiprog.pl firstName=todd&lastName=wade
>
> Todd W.
>
> --
> To unsubscribe, e-mail: beginners-unsubscribe@perl.org
> For additional commands, e-mail: beginners-help@perl.org


Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About