Re: Perl to CGI
by BigJoe (Curate) on Aug 17, 2000 at 20:12 UTC
|
If you use the CGI.pm module it will ask you for the form input in pairs name=BigJoe site=perlmonks
Also if you post some code we can take a look and see what is going on.
--BigJoe
Learn patience, you must. Young PerlMonk, craves Not these things. Use the source Luke. | [reply] |
RE: Perl to CGI
by KM (Priest) on Aug 17, 2000 at 20:10 UTC
|
It could be permissions, maybe you aren't printing out a header, are you using CGI::Carp qw(fatalsToBrowser)? What is the server error?
Cheers,
KM | [reply] |
|
|
It's not permissions, I've already set those correctly. I'm not using CGI.pm, I'll try that in a sec. It is printing out a correct header because it prints it out with the program's error messages when I run it from the command line.
I'll see about posting a test version somewhere in a bit.
I don't have access to the server log, I'm just a lowly webpage designer.
Ther server error that I get is:
Server Error
This server has encountered an internal error which prevents it from fufilling your request. The most likely cause is a misconfiguration. Please ask the administrator to look for messages in the server's error log.
I've learned that this is the error the server returns for everything tho' so....
She-wolf
"Wha? I don't get it."
| [reply] |
RE: Perl to CGI
by Cirollo (Friar) on Aug 17, 2000 at 20:16 UTC
|
It appears that you aren't using CGI.pm (using it is a Good Idea) so if you want to test your program with variables, you can either just write them into the program ($cgi_var = "foo";) or you can use the perl debugger (with perl -d) and set variables by hand there.
You should be able to see your errors in the server error log, and if you want errors to go to the browser, take a look at CGI::Carp. use CGI::Carp qw(fatalsToBrowser); will send error messages to the browser. | [reply] [d/l] |
RE: Perl to CGI
by Boogman (Scribe) on Aug 17, 2000 at 20:20 UTC
|
If you can get at the servers logs, the error log should tell you what the problem is. In apache its under the logs directory with the name error.log...
One thing you could check is to see if you are printing out the correct headers for a html document. Every once in a while I've forgotten those... | [reply] |
(crazyinsomniac) RE: Perl to CGI
by crazyinsomniac (Prior) on Aug 17, 2000 at 23:49 UTC
|
#!/usr/bin/perl -w
BEGIN
{#outputs al errors to $logfile
my $logfile = "logfile.log";
use CGI::Carp qw(carpout);
open(LOG, ">$logfile") or die "Unable to write to $logfile: $!";
carpout(*LOG);
}#
The above code should take care of not being able to access the error log by providing you with your own.
The above code error log will overwrite ( > ) the log each time your cgi is run. If you want to append just add another > (open ( LOG, ">>$logfile" ) ).
However you're still using sprite, and like athomason and merlyn suggested in your previoius post sprite is ancient and there's better solutions.
"cRaZy is co01, but sometimes cRaZy is cRaZy".
- crazyinsomniac | [reply] [d/l] |
|
|
| [reply] |
|
|
Have you consisdered simply installing modules in your home directory - if you have one. At least it would be under your control and you'd have permissions to install there. Then you need to make sure that you include something like
use /path/to/module/module::name;
or push the library path to the @INC variable
push (@INC,/path/to/module/module.pm);
in the top of your scripts.
MadraghRua
| [reply] |
|
|
|
|
| [reply] |
|
|
Anytime text (via std or err output) is returned from a cgi it goes back to the browser.
If any text precedes(it usually does) the header ("Content-type: text/html\n\n" in the case of an html page) then the browser will think something is wrong. (It will think it is receiving a bad header.)
On the possibility of permissions problems. I have a few hosted sites that prevents any cgi from executing if the directory the script is in has potentially insecure permissions. (group/other read/write needed to be turned off, this might apply to the script too)
It may help, it's caught me several times.
| [reply] |
Re: Perl to CGI
by She-wolf (Sexton) on Aug 17, 2000 at 21:23 UTC
|
| [reply] |
|
|
First, you should use warnings (-w) and strict. Next, you should convert this to use CGI.pm, next add in CGI::Carp. This is very Perl4ish as it is and I would rather take the time to help debug it when it is, um, "updated" :) After making those changes, the problem itself may go away or become more apparant.
Cheers,
KM
| [reply] |
Re: Perl to CGI
by She-wolf (Sexton) on Aug 17, 2000 at 20:50 UTC
|
| [reply] |
|
|
You don't have permission to access /ergh.txt on this server.
Cheers,
KM
| [reply] |
Re: Perl to CGI
by tenatious (Beadle) on Aug 18, 2000 at 06:22 UTC
|
The following will trap some errors. Other problems could be related to your permissions, where you are outputting the stuff (/output.txt looks like it resides in the root directory, not in a directory writable by "nobody")
at the beginning of the script do:
## Use the fabulous CGI.pm module is usually installed
use CGI;
my $C = CGI->new();
## create a code ref to the DIE event handler
$SIG{__DIE__} = \&my_die;
## create a sub to handle the dies
sub my_die {
print $C->header,$C->start_html;
print qq(<p>@_</p>);
print $C->end_html;
}
and let it go.
When you use the CGI module you can also pass parameters to the script from the command line that you would pass from the form. i.e.:
$ ./my_script.cgi username=tenatious password=hideyho! age=1000 IQ=1
and lastly, make sure that the script is world executable:
chmod o+x my_script.cgi
| [reply] [d/l] [select] |
|
|
That's almost exactly what
use CGI::Carp qw(fatalsToBrowser);
does. Nice shiny, reinvented, wheel. {grin}
-- Randal L. Schwartz, Perl hacker | [reply] [d/l] |
RE: Perl to CGI
by Jouke (Curate) on Aug 18, 2000 at 11:12 UTC
|
I'm not sure if my $0.02 will be able to help you, but there's a standard way for me to debug my scripts, and everywhere I go where people see me doing it, they say "Hey, I didn't know that was possible":
1. Make sure you have ptkdb (TK debugger) installed
2. Setup a local webserver (a development server if you wish), with a configuration similar to your production server.
3. Run the scripts with #!/usr/local/bin/perl -d (and whatever you like after that).
Now try to access your script, and voila: your debugger will open with all parameters and things set the way your script uses them normally.
This can save a lot of trouble...at least it did (and does) for me.
Jouke | [reply] |