SPUG: generating output with a cgi script
yaoxi.wu at attws.com
Mon Oct 2 16:40:46 CDT 2000
Thank everyone for the suggestions and hints! With your help, I have fixed
the problems and my script is working!
Following one of suggestions, I wrote a function to display the error
message on the web browser (a simple "die ..." statement would cause the
server to display something like "an internal error ..." which was not very
helpful), and found out that the "open file" failed. The problem was with
the file permission. The script and the text file were owned by the same
person and the text file could only be rwx'ed by the owner. This explains
that why running the script off-line had no problem. My guess for it not to
run under the web server is that the server was run by "nobody" who had no
permission to read the file. Modifying the file permission solved the
problem. Does this mean that every data file to be accessd by the server
must be owned by "nobody" or "world-readable"?
As someone suggested, the second problem was caused by typos. Sorry about
that. The fact that the script run successfully off-line the first time made
me wondering that the two problems had the same cause, probably
misconfigured perl compiler or web server.
By the way, does anyone know a debugger program available for perl?
Something similar to DDD for C?
Again, thank you all so much for the help!
From: JP Montagnet [mailto:jope at n2h2.com]
Sent: Monday, October 02, 2000 11:01 AM
To: Wu, Yaoxi
Subject: Re: SPUG: generating output with a cgi script
On Mon, 2 Oct 2000, Wu, Yaoxi wrote:
> This thing is driving me crazy; I hope someone can enlighten me.
> Please look at the following short cgi script:
> #!/usr/bin/perl -wT
> use CGI;
> $cgi = new CGI;
> print $cgi->header("text/plain");
> open(DB_FILE, "test.bib");
> undef $/;
> close DB_FILE;
My guess is that your open() statement failed, because you specified the
file relative to whatever the current directory is. When your script is
running as a CGI scrpt, that very well may not be the same directory the
script is in. Either fully qualify your file location, or add a chdir()
prior to the open(). CHeckingthe return code from your open() is always
a good idea too.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
Subscriptions; Email to majordomo at pm.org: ACTION LIST EMAIL
Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest
Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/
More information about the spug-list