Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

No output from CGI script when using CGI::Debug

by pagespank (Initiate)
on Nov 07, 2011 at 19:01 UTC ( [id://936560]=perlquestion: print w/replies, xml ) Need Help??

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

Hi there,

I'm using a bunch of scripts that use CGI::Debug to catch errors. Over the weekend, seemingly randomly this has stopped working, and now I get the following error every time I run the script:

"Your program doesn't produce ANY output!"

Yet, if I comment out the use CGI::Debug; line, it works just fine, which wasn't the case a couple of days ago. The following example is a very simplified version of what will throw up the error (and yes I am sending the CGI param when getting the error...)

#!/usr/bin/perl -wT use strict; use CGI qw(:standard); use CGI::Debug; my $t = param("foo"); print "content-type: text/html\n\n"; print $t;

Any ideas on what might cause this to happen suddenly? I've been through the CPAN logs on the server, looked at file permissions, command logs etc, but can't find anything which would have caused this!! Any ideas greatly appreciated.

----

Update: Problem solved; it was CGI::Debug that got caught in an infinite loop over the weekend, filled up the temp directory with too many logs, then failed every time it was called after the weekend! Be warned when using CGI::Debug to check for this!!

Replies are listed 'Best First'.
Re: No output from CGI script when using CGI::Debug
by chromatic (Archbishop) on Nov 07, 2011 at 20:34 UTC

      Yep it's still installed, however I think the error may lie not with CGI::Debug per se.

      My scripts are outputting plain text to the browser ok without CGI::Debug; however when I try a script that exports attachments (ie using Spreadsheet::WriteExcel), I now get a bunch of weird characters, followed by the HTML of the page with messed up line breaks.

      Very weird but perhaps Apache related? Am running on RHEL 5 & Apache 2.2.3

        If you are trying to stream a spreadsheet to a browser, you'll need to define a different content-type. Browsers don't automatically know what the web server is sending, you define that in the content-type(also known as MIME). The code snippet above is telling the browser, "Hey, what I'm about to send you is text/html". So if the web server outputted excel binary code instead, the browser will render it as funny text.
Re: No output from CGI script when using CGI::Debug
by johnny_carlos (Scribe) on Nov 07, 2011 at 21:09 UTC
    I think it might be because you are printing the content header manually, and not using the CGI.pm methods such as:
    print header; print start_html;

Log In?
Username:
Password:

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

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

    No recent polls found