473,377 Members | 1,153 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,377 software developers and data experts.

Printing errors to browser

Kelicula
176 Expert 100+
Does anyone know of a way that I can have the errors on a cgi script be funneled to the http output?

I have use warnings, and the

Expand|Select|Wrap|Line Numbers
  1. or die "can't open it $!\n";
But still to this day I have never seen what is in $!. Or recieved a warning.

All I ever get is Internal server error, or it works.

Another thing that is very weird, I was working on this set transparant color, with the GD module, and it worked fine. Here is the script:

Expand|Select|Wrap|Line Numbers
  1. #!user/bin/perl
  2.  
  3. use strict;
  4. use warnings;
  5. use GD;
  6.  
  7. my $image = GD::Image->newFromJpeg("../img/logoTest.jpg");
  8. my $black = $image->colorResolve(0,0,0);
  9. $image->transparent($black);
  10. $image->interlaced('true');
  11. my ($width,$height) = $image->getBounds();
  12. my $count = 0;
  13. for (my $x = 0; $x < $width; $x++) {
  14.      for (my $y = 0; $y < $height; $y++) {
  15.          my $color = $image->getPixel($x,$y);
  16.          my ($r,$g,$b) = $image->rgb($color);
  17.          if ($r < 30 && $g < 30 && $b < 30) {
  18.              $image->setPixel($x,$y,$black);
  19.              $count++;
  20.          }
  21.      }
  22.  }
  23. print "$count\n";
  24. open(FILE, ">../img/background2.png") || die "Cannot open background2.jpg: $!\n";
  25. print FILE $image->png;
  26.  
However I noticed that I had grabbed the wrong jpg to set transparency for, so I changed it
Expand|Select|Wrap|Line Numbers
  1. my $image = GD::Image->newFromJpeg("../img/otherOne.jpg");
And now it doesn't work. Internal error.

I have looked through it for hours now, and can't see what I messed up. I litarally just changed four or five characters.

I'd love to get the errors to the screen
Thanks!!

PS -
I tried running it on my local machine, but it says GD is not found. Can't open GD/Image found in C:/perl/bin/lib (or whatever the path was I'm not looking at the error now)
Sep 9 '07 #1
3 2007
numberwhun
3,509 Expert Mod 2GB
Does anyone know of a way that I can have the errors on a cgi script be funneled to the http output?

I have use warnings, and the

Expand|Select|Wrap|Line Numbers
  1. or die "can't open it $!\n";
But still to this day I have never seen what is in $!. Or recieved a warning.

All I ever get is Internal server error, or it works.

Another thing that is very weird, I was working on this set transparant color, with the GD module, and it worked fine. Here is the script:

Expand|Select|Wrap|Line Numbers
  1. #!user/bin/perl
  2.  
  3. use strict;
  4. use warnings;
  5. use GD;
  6.  
  7. my $image = GD::Image->newFromJpeg("../img/logoTest.jpg");
  8. my $black = $image->colorResolve(0,0,0);
  9. $image->transparent($black);
  10. $image->interlaced('true');
  11. my ($width,$height) = $image->getBounds();
  12. my $count = 0;
  13. for (my $x = 0; $x < $width; $x++) {
  14.      for (my $y = 0; $y < $height; $y++) {
  15.          my $color = $image->getPixel($x,$y);
  16.          my ($r,$g,$b) = $image->rgb($color);
  17.          if ($r < 30 && $g < 30 && $b < 30) {
  18.              $image->setPixel($x,$y,$black);
  19.              $count++;
  20.          }
  21.      }
  22.  }
  23. print "$count\n";
  24. open(FILE, ">../img/background2.png") || die "Cannot open background2.jpg: $!\n";
  25. print FILE $image->png;
  26.  
However I noticed that I had grabbed the wrong jpg to set transparency for, so I changed it
Expand|Select|Wrap|Line Numbers
  1. my $image = GD::Image->newFromJpeg("../img/otherOne.jpg");
And now it doesn't work. Internal error.

I have looked through it for hours now, and can't see what I messed up. I litarally just changed four or five characters.

I'd love to get the errors to the screen
Thanks!!

PS -
I tried running it on my local machine, but it says GD is not found. Can't open GD/Image found in C:/perl/bin/lib (or whatever the path was I'm not looking at the error now)
One of our resident experts (KevinADC), has written a tutorial on CGI under the Articles section of this site. In there, under the Modules section, you will find the following:

Expand|Select|Wrap|Line Numbers
  1. use CGI::Carp qw/fatalsToBrowser/;
  2.  
along with an explanation. I recommend the tutorial as it is an excellent beginning. (as far as I have seen as I am still reading it)

Regards,

Jeff
Sep 9 '07 #2
KevinADC
4,059 Expert 2GB
To expand on that, you can aso print warnings. see the "MAKING WARNINGS APPEAR AS HTML COMMENTS" in the CGI::Carp documentation.
Sep 9 '07 #3
KevinADC
4,059 Expert 2GB
There is a new module that looks interesting:

CGI::Carp::DebugScreen
Sep 9 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Vince | last post by:
I have a generic page that I use for printing content, and it contains an iframe into which I put the url for the page to be printed. I dynamically size the iframe so that it correctly displays...
0
by: Nigel | last post by:
I successfully create a .NET Component (Visual Basic .NET) that would print, unfortunately when used within a web browser it appears that .NET security doesn't allow you to run code that interacts...
4
by: IntraRELY | last post by:
Hello All, I am developing a Web Application in VB.NET. We are printing checks from a IE 6.0. Here are our requirments: 1. Checks will be printed on pre-printed stock, so we must format the...
3
by: John Peterson | last post by:
Hello all! I'm at my wits end trying to search for what I assumed to be a relatively straightforward task. I have a Web application written in C#, and I have a button on the form that I want to...
1
by: eskildb | last post by:
First, please be gently. I am fairly new to the programming world (1.5 years with some expermentation prior to). I have been working on a project that has to print HTML pages with graphics in a...
1
by: eskildb | last post by:
First, please be gently. I am fairly new to the programming world (1.5 years with some expermentation prior to). I have been working on a project that has to print HTML pages with graphics in a...
12
by: Alex Clark | last post by:
Greetings, (.NET 2.0, WinXP Pro/Server 2003, IE6 with latest service packs). I've decided to take advantage of the layout characteristics of HTML documents to simplify my printing tasks, but...
6
by: Siv | last post by:
Hi, I am getting into printing with VB.NET 2005 and want to implement the usual capability that a user can select a selection of pages. I have a report that is generated by my application that if...
8
by: Neo Geshel | last post by:
Greetings. BACKGROUND: My sites are pure XHTML 1.1 with CSS 2.1 for markup. My pages are delivered as application/xhtml+xml for all non-MS web clients, and as text/xml for all MS web...
18
by: Brett | last post by:
I have an ASP.NET page that displays work orders in a GridView. In that GridView is a checkbox column. When the user clicks a "Print" button, I create a report, using the .NET Framework printing...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.