Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

CGI on the console

by raflach (Pilgrim)
on May 10, 2005 at 02:14 UTC ( [id://455394]=perlquestion: print w/replies, xml ) Need Help??

raflach has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I have a CGI on which I am trying to troubleshoot a 500 error. I have all environment variables set appropriately, but...

I don't remember how to do the following:

pass POST data to the cgi.

I never did know how to do the following:

emulate a set cookie.

I know I've seen it in the perl docs (or my books) somewhere, but haven't had luck searching. Hoping someone will take pity and save me the endless search. Just a pointer to the correct documentation would be enough.

Replies are listed 'Best First'.
Re: CGI on the console
by eibwen (Friar) on May 10, 2005 at 02:18 UTC

    The pod for CGI as well as perlfaq9 should help. If you're trying to POST from a CGI, Super Search should help you locate posts on this very topic (I know I answered one awhile back, anyway).

      Neither CGI nor perlfaq9 offer any information on the topic of running cgi scripts from the console (i.e., from a command line typing /usr/bin/perl -w ./mycgiscript.cgi). Super Search was also of no help in locating appropriate topics (I did do at least a modicum of research before posting in the first place).

        Actually, CGI does have information on this. Look for the section called "DEBUGGING". I just went there, searched for "command" (as in "command line" or "commandline"), and eventually found this section. I think it has exactly the details you're looking for.

Re: CGI on the console
by adamk (Chaplain) on May 10, 2005 at 05:21 UTC
    As usual, CPAN knows all.

    CGI::Capture was written to replace CGI.pm's pitiful save functionality, and does exactly what you want, including the environment file uploads, cookies, checking you are the same user, etc etc etc.

    It lets you "record" a CGI call to a file, and then play it back as many times as you want.
Re: CGI on the console
by brian_d_foy (Abbot) on May 10, 2005 at 04:38 UTC
Re: CGI on the console
by davidrw (Prior) on May 10, 2005 at 02:39 UTC
    There's a few CGI-related nodes in the Tutorials section. I found this useful node in there that says (read the node for the whole context/discussion):
    open(FILE, "<data.txt") or die "gah!"; my $query = CGI->new(FILE); ...
    Where data.txt contains stuff like...
    foo=bar baz=biz
Re: CGI on the console
by Perimus (Novice) on May 10, 2005 at 07:30 UTC
    For debugging CGI,
    use CGI::Carp qw/fatalsToBrowser/;
    can be quite helpful.

    Instead of getting a 500 error, you should get a screen with error messages. Doesn't work in all situations, especially when you're getting the error because the web server isn't executing the script at all.

    Some things that might cause that...
    - shebang line (does /usr/local/bin/perl really exist?)
    - execute permissions on the file (chmod)
    - apache ExecCGI directive for the file's location
    - apache's access and suexec log (file owned by correct user/group?)

    Good Luck

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://455394]
Approved by Errto
Front-paged by diotalevi
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2024-04-26 08:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found