Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

CGI redirect

by xyzzy (Pilgrim)
on Oct 29, 2009 at 18:20 UTC ( [id://804013]=perlquestion: print w/replies, xml ) Need Help??

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

I have a script using CGI (standard mode) which is failing oddly. The script looks something like this:

if (defined param('fnord')) { # open log file and append some params... redirect(-uri => 'http://whoisxyzzy.com/fnord/', -status => '303') +; } else { # do some other stuff... }

The script originally just handled a query and generated a corresponding page. Then I decided to add another parameter, which if present would dump to a log and redirect. Everything works, but if 'fnord' is included in the query instead of getting redirected I get a 500. The log file is still updated, even when I (originally) had the redirect call before the logging, and when 'fnord' is undef it works as it did before I decided to be clever and add this lack of functionality.

UPDATE: I am an idiot. redirect() does not actually redirect, it only generates the header and requires a preceding print statement. XYZZY OUT!

$,=qq.\n.;print q.\/\/____\/.,q./\ \ / / \\.,q. /_/__.,q..

Replies are listed 'Best First'.
Re: CGI redirect
by moritz (Cardinal) on Oct 29, 2009 at 18:30 UTC
    Look in the error log of your web server, it will tell you more details than just a 500.
    Perl 6 - links to (nearly) everything that is Perl 6.
      Unfortunately the hosting service I signed up with uses cPanel and doesn't SSH. I have no idea where the actual logs are tucked away or if I can access them. The only "Error log" that is available only shows favicon 404s... but hey, it was cheap...
      $,=qq.\n.;print q.\/\/____\/.,q./\ \ / / \\.,q.    /_/__.,q..

        You still have options:

        • See if CGI::Carp qw(fatalsToBrowser); is of any use
        • Install a web server locally and test your script there
        • Run your script locally (without a web server) and see if you can make any sense of the output
        Perl 6 - links to (nearly) everything that is Perl 6.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2025-05-23 05:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.