This is a discussion on apache2 CGI Perl config problems? within the Linux Web Servers forums, part of the Web Server and Related Forums category; Running Mandrake 9.1, apache2. I have a CGI Perl script that uses (from the LWP::Simple module) the 'get' ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Running Mandrake 9.1, apache2.
I have a CGI Perl script that uses (from the LWP::Simple module) the 'get' and 'head' commands to gather information about a website. It returns content-type text/vnd.wap.wml but I don't think that's the problem (I've set up the MIME types and get the same problem using text/html). When I run the script from shell as a user or root, the 'get' and 'head' commands work fine. However, when I access the script through a web browser, although the 'get' still works, the 'head' call returns false, meaning there was an error access the website. Does anyone know what's going on? I'm pretty sure it's a problem with the server configuration, not the modules, but I'm open to any suggestions. I have the same problem on a Redhat 7.3 machine running apache 1.3. I'd appreciate any help. Thank you! :-) Mitchua |
|
|||
|
"cp" <cpryce@pryce.net> wrote in message
news:240620031117080773%cpryce@pryce.net... <SNIP> > I might. But you haven't provided any code that illustrates the > problem, so it's hard to tell. I wrote a test program to demonstrate the problem. Here's the code: #!/usr/bin/perl -w use LWP::Simple; print "Content-type: text/html\n\n"; my @headinfo = head($ARGV[0]); if (@headinfo) { print @headinfo . "Got header information\n"; print "Modified date: " . localtime($headinfo[2]) . "\n"; } else { print @headinfo . "Problem with head\n"; } my $content = get($ARGV[0]); if ($content) { print "Got content too!\n"; } When I run it on the Mandrake machine with http://mandrakemachine_address/cgi-b...www.netkee.com I get a webpage: "5Got header information Modified date: Sun May 18 11:01:19 2003 Got content too! " When I run it on the Redhat machine with http://redhatmachine_address/cgi-bin...www.netkee.com I get a webpage: "0Problem with head Got content too! " So like I said, both machine are getting the page, but the redhat machine is getting nothing from it's 'head' call for some reason. Thanks for your help, Mitchua |
|
|||
|
"David Efflandt" <efflandt@xnet.com> wrote in message <SNIP
> Try printing out $ARGV[0] once and see what it contains (might not be what > you think it is). If you want to use the query string for something, you > generally need to parse (and convert any special characters) from > $ENV{QUERY_STRING} (or set a variable name in query string and use CGI > module). I had noticed that when I enter addresses with ~'s in them, a \ is placed before it. However, in the URL I ran that test with (http://www.netkee.com), I just tried outputting ARGV[0] and it looked exactly like I entered it. > > It also may be enlightening printing actual content returned by the > head() or get(), at least for testing. You are just printing a line count > for head and nothing useful for get. > Someone else suggested this and gave me a test program to run. As you can see though, it ran into some troubles: _____________________ "Cat" <cat@no-spam.com> wrote in message news:3EF980B2.6861621D@no-spam.com... <SNIP> > Hi, I'd like to know what is actually in @headinfo. Can you > run the following and tell us what you get for both boxes > > #!/usr/bin/perl > use strict; > use warnings; > use LWP::Simple; > > my @headinfo = head($ARGV[0]); > > print scalar(@headinfo) . " items in header\n"; > foreach my $item (@headinfo) { > print "> $item\n"; > } No problem, here's the results: Redhat 7.3 box: When I first ran it I got ": bad interpreter: No such file or directory". I added a '-w' on the sh-bang line and it run, outputting '0 items in header'. Mandrake 9.1 box: I got the same 'bad interpreter' error. I added '-w' and it ran with the following output: 5 items in header > text/html Use of uninitialized value in concatenation (.) or string at ../ngtest.cgi line 10. >. Use of uninitialized value in concatenation (.) or string at ../ngtest.cgi line 10. >. Use of uninitialized value in concatenation (.) or string at ../ngtest.cgi line 10. >. Use of uninitialized value in concatenation (.) or string at ../ngtest.cgi line 10. >. _________________ Hope this helps. Thanks for the reply. Mitchua |
|
|||
|
On Wed, 25 Jun 2003 15:33:13 GMT, Mitchua <mitchua@yahoo.com> wrote:
> "David Efflandt" <efflandt@xnet.com> wrote in message <SNIP >> Try printing out $ARGV[0] once and see what it contains (might not be what >> you think it is). If you want to use the query string for something, you >> generally need to parse (and convert any special characters) from >> $ENV{QUERY_STRING} (or set a variable name in query string and use CGI >> module). > > I had noticed that when I enter addresses with ~'s in them, a \ is placed > before it. However, in the URL I ran that test with > (http://www.netkee.com), I just tried outputting ARGV[0] and it looked > exactly like I entered it. Try following instead which will fix that and add tags for each variable. The "bad interpretter" thing sounds like the script may have been corrupted by touching Windows (wrong line endings, so shell could not find "perl^M"). Note that my apache does not seem to return anything for size and modified (or expire, since that does not apply to normal resources): #!/usr/bin/perl use strict; use warnings; use LWP::Simple print "Content-type: text/plain\n\n"; $ARGV[0] =~ s/\\//g; print "$ARGV[0]\n\n"; my @headinfo = head($ARGV[0]); print scalar(@headinfo) . " items in header\n"; my @label = qw/Type Length Modified Expires Server/; my $i; for ($i=0;$i<5;$i++) { print "$label[$i]: "; print $headinfo[$i] if $headinfo[$i]; print "\n"; } -- David Efflandt - All spam ignored http://www.de-srv.com/ http://www.autox.chicago.il.us/ http://www.berniesfloral.net/ http://cgi-help.virtualave.net/ http://hammer.prohosting.com/~cgi-wiz/ |
| Thread Tools | |
| Display Modes | |
|
|