Gossamer Forum
Home : General : Perl Programming :

Avoiding to download CGI or PL

Quote Reply
Avoiding to download CGI or PL
Hello to all,
Is there a snipped of code to put inside a perl script as to stop downloading the script when an error occurs.

I a making my debuts in writing a small perl script.
But when it goes in error a screen appears that says:

"You have choosen to download a file named myscript.pl"
"Save to Disk or open from this location"

I would like to avoid that when have error then people can download the script.

Thanks for any help offered
Regards,
Sanuk

Quote Reply
Re: Avoiding to download CGI or PL In reply to
Hi:

Odds are that you are not downloading the script, but you are downloading the error message since it is passed as plain text and not html. Try changing:

print "Content-type: text/plain\n\n";

to:

print "Content-type: text/html\n\n";


Dan Cool

LotusLand
Vancouver, BC, Canada
Top Ranked City in World for Quality of Life
Quote Reply
Re: Avoiding to download CGI or PL In reply to
Pass possible errors to a sub that will show them, or use

use CGI::Carp qw(fatalsToBroswer);

Installations:http://www.wiredon.net/gt/
Favicon:http://www.wiredon.net/favicon/

Quote Reply
Re: Avoiding to download CGI or PL In reply to
Hi Paul
How exactly to add a CGI line to pass
Fatals to Browser.
Could you please post the exact lines to add
Thank You and Regards,
Sanuk

Quote Reply
Re: Avoiding to download CGI or PL In reply to
I am not exactly sure what you are asking but to use paul's example above your code would look like this:

#!/usr/bin/perl
use CGI::Carp qw(fatalsToBroswer);

# Put the rest of your code below and this will report most
# errors to the browser.

I hope that helps

Regards
~Charlie

Quote Reply
Re: Avoiding to download CGI or PL In reply to
Thanks guys
Now it works
It didnt work because I copied Paul Text:
"use CGI::Carp qw(fatalsToBroswer);"

Where it should to be:
"use CGI::Carp qw(fatalsToBroWSer);"

Thanks Paul and Piper Charlie for the Help
Regards,Sanuk


Quote Reply
Re: Avoiding to download CGI or PL In reply to
Ack sorry - hands moving quicker than my eyes again!

Installations:http://www.wiredon.net/gt/
Favicon:http://www.wiredon.net/favicon/