Re: cgi and mod_perl-1.26, Apache-1.27, perl-5.8.0, FreeBSD failwith 'The document contained no data'
George Savvides wrote: Hi all, I am having problems running cgi scripts under mod_perl. I realise that this question has been asked before but I have not been able to find a reference to this particular behaviour in the manuals or newsgroups. Problem summary --- Scripts running under mod_perl fail. Netscape returns the popup 'The document contained no data' Nothing is printed in the browser window. Scripts that use the mod_perl api work OK. Example scripts --- The cgi script below fails. #!/usr/bin/perl -w print "Content-type: text/plain\n\n"; print "Hello World\n"; The mod_perl api script below works. my $r = Apache->request; $r->content_type("text/plain"); $r->send_http_header; $r->print("Hello World"); Script configuration Alias /perlbin ${TOP}/perlbin PerlModule Apache::Registry SetHandler perl-script Perlhandler Apache::Registry Options +ExecCGI allow from all PerlSendHeader On Machine config -- The cgi script fails on this box: FreeBSD 4.5-RELEASE-p23 Apache/1.3.27 perl-5.8.0 mod_perl-1.26 The same cgi script with the same script config works fine on this one: FreeBSD 4.5-RELEASE-p23 Apache/1.3.20 perl-5.005_03 mod_perl-1.26 It looks as if the CGI script is not returning its stdout to the browser but I can't for the life of me see why. Any help would be very much appreciated. What has error_log to say about this? Do you have the file perms right? __ Stas BekmanJAm_pH --> Just Another mod_perl Hacker http://stason.org/ mod_perl Guide ---> http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com
Re: cgi and mod_perl-1.26, Apache-1.27, perl-5.8.0, FreeBSD failwith 'The document contained no data'
Hi Stas, Thanks for your reply. The file perms are correct and nothing is printed to the logs. The scripts do run. If you write a script with a redirect in it for instance, the redirect is made. They just don't seem to print anything to stdout. Regards, George Savvides. Stas Bekman wrote: > > What has error_log to say about this? Do you have the file perms right? > > __ > Stas BekmanJAm_pH --> Just Another mod_perl Hacker > http://stason.org/ mod_perl Guide ---> http://perl.apache.org > mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com > http://modperlbook.org http://apache.org http://ticketmaster.com
Re: cgi and mod_perl-1.26, Apache-1.27, perl-5.8.0, FreeBSD failwith 'The document contained no data'
Hi Lee, Thanks for your reply. I tried the script you sent and it failed with "document contains no data". This is odd because I previously found that mod_perl API scripts ran ok but CGI scripts running under mod_perl failed. The script printed some output in the log which I have attached below. I've also attached the earlier messages in the thread in case they might help. Any further comments much appreciated. George Savvides. Script output = I've edited the output, removing most of the HTML which is quite long, please let me know if I've left out something important. Connection: close Date: Mon, 03 Feb 2003 09:36:13 GMT Server: Apache Content-Type: text/html Client-Date: Mon, 03 Feb 2003 09:36:13 GMT Client-Peer: 194.203.134.150:80 Link: ; rel="stylesheet"; type="text/css" Title: xxx - anti-virus for business X-Meta-Description: xxx Anti-Virus, leading anti-virus developer, provide information and software designed to counter computer viruses, trojan horses, and virus hoaxes. Software available for download. X-Meta-Generator: HTML Tidy for FreeBSD (vers 1st February 2002), see www.w3.org X-Meta-Keywords: xxx, anti-virus, anti virus, antivirus, data security, software, SWEEP, InterCheck, Windows, Windows 3.1x, DOS, Windows 95/98, Windows NT, OS/2, NetWare, OpenVMS, Unix, Macintosh, Windows 2000, free, protection, downloads gateway virus protection X-Meta-MSSmartTagsPreventParsing: TRUE Apache::ROOTse_2diceland_2exxx_2ecom::perlbin::testwarn_2epl::handler('Apache=SCALAR(0xb094330)') called at /usr/local/lib/perl5/site_perl/5.8.0/i386-freebsd/Apache/Registry.pm line 143 eval {...} called at /usr/local/lib/perl5/site_perl/5.8.0/i386-freebsd/Apache/Registry.pm line 143 Apache::Registry::handler('Apache=SCALAR(0xb094330)') called at /dev/null line 0 eval {...} called at /dev/null line 0 etc ... html Apache::ROOTse_2diceland_2exxx_2ecom::perlbin::testwarn_2epl::handler('Apache=SCALAR(0xb094330)') called at /usr/local/lib/perl5/site_perl/5.8.0/i386-freebsd/Apache/Registry.pm line 143 eval {...} called at /usr/local/lib/perl5/site_perl/5.8.0/i386-freebsd/Apache/Registry.pm line 143 Apache::Registry::handler('Apache=SCALAR(0xb094330)') called at /dev/null line 0 eval {...} called at /dev/null line 0 Previous messages in thread === My original message --- Hi all, I am having problems running cgi scripts under mod_perl. I realise that this question has been asked before but I have not been able to find a reference to this particular behaviour in the manuals or newsgroups. Problem summary --- Scripts running under mod_perl fail. Netscape returns the popup 'The document contained no data' Nothing is printed in the browser window. Scripts that use the mod_perl api work OK. Example scripts --- The cgi script below fails. #!/usr/bin/perl -w print "Content-type: text/plain\n\n"; print "Hello World\n"; The mod_perl api script below works. my $r = Apache->request; $r->content_type("text/plain"); $r->send_http_header; $r->print("Hello World"); Script configuration Alias /perlbin ${TOP}/perlbin PerlModule Apache::Registry SetHandler perl-script Perlhandler Apache::Registry Options +ExecCGI allow from all PerlSendHeader On Machine config -- The cgi script fails on this box: FreeBSD 4.5-RELEASE-p23 Apache/1.3.27 perl-5.8.0 mod_perl-1.26 The same cgi script with the same script config works fine on this one: FreeBSD 4.5-RELEASE-p23 Apache/1.3.20 perl-5.005_03 mod_perl-1.26 It looks as if the CGI script is not returning its stdout to the browser but I can't for the life of me see why. Any help would be very much appreciated. George Savvides Reply from Stas Bekman -- What has error_log to say about this? Do you have the file perms right? Lee Goddard wrote: > > -BEGIN PGP SIGNED MESSAGE- > Hash: MD5 > > Hi George, > > I've not seen any of this thread other than what's > below, but have you had all the headers output correctly? > > Try running this after setting $url, and see what you get: > > use LWP::UserAgent; > $url = "http://195.117.126.24";; > $ua = LWP::UserAgent->new; > $req = new HTTP::Request('GET', $url); # Format URL request > $res = $ua->request($req); > if (not $res->is_success()) { > die "...failed:\n" . $res->error_as_HTML > } > warn $res->headers_as_string; > warn $res->content; > #open OUT, ">/test.html"; > #print OUT $res->content; > #close OUT; > exit; > > Lee > > On Sunday, February 2, 2003 at 7:42:12 PM, you wrote: > > GS> Hi Stas, > > GS> Thanks for your reply. > > GS> The file perms are correct and nothing is printed to the logs. > GS> The scripts do run. If you write a script with a redirect in it > GS> for instance, the redirect is made. They just don't seem to > GS> print anything to stdout. > > GS> Regards, George Savvides. > > GS> Stas Bek
Re: cgi and mod_perl-1.26, Apache-1.27, perl-5.8.0, FreeBSD failwith 'The document contained no data'
Lee Goddard wrote: [...] I don't know: you're doing this: print "Content-type: text/plain\n\n"; print "Hello World\n"; Does it (probably not) make any difference if you do a full CRLF, as perldoc perlop: For example, most networking protocols expect and prefer a CR+LF (""\015\012"" or ""\cM\cJ"") for line terminators, and although they often accept just ""\012"", they seldom tolerate just ""\015"". If you get in the habit of using ""\n"" for networking, you may be burned some day. Apache already fixes up "\n\n" to the right thing. What it really does is identifying the Content-type: header, and then adds the terminating by itself, because it really sends other headers, before adding an empty new line. So it shouldn't matter if you say "\r\n\r\n" or just "\n\n", unless there is a bug. __ Stas BekmanJAm_pH --> Just Another mod_perl Hacker http://stason.org/ mod_perl Guide ---> http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com
Re: cgi and mod_perl-1.26, Apache-1.27, perl-5.8.0, FreeBSD failwith 'The document contained no data'
Hi guys, Thanks for your replies. Problem still not solved but I'll let you know if I find an answer. George. Lee Goddard wrote: > > -BEGIN PGP SIGNED MESSAGE- > Hash: MD5 > > Hi Stas, > > On Tuesday, February 4, 2003 at 2:47:43 AM, you wrote: > > SB> Lee Goddard wrote: > SB> [...] > >> I don't know: you're doing this: > >> > >> print "Content-type: text/plain\n\n"; > >> print "Hello World\n"; > >> > >> Does it (probably not) make any difference if > >> you do a full CRLF, as perldoc perlop: > >> > >> For example, most networking protocols expect > >> and prefer a CR+LF (""\015\012"" or ""\cM\cJ"") for line terminators, > >> and although they often accept just ""\012"", they seldom tolerate just > >> ""\015"". If you get in the habit of using ""\n"" for networking, you > >> may be burned some day. > > SB> Apache already fixes up "\n\n" to the right thing. What it really does > SB> is identifying the Content-type: header, and then adds the terminating > SB> by itself, because it really sends other headers, before adding an > SB> empty new line. So it shouldn't matter if you say "\r\n\r\n" or just > SB> "\n\n", unless there is a bug. > > So if Apache (mod_perl) adds this to his script, even > though it is not a mod_perl script, then shouldn't he > be calling it from a that isn't mod_perl > enabled...? > > Sorry, just getting into this Apache module thing > > Cheers > lee > > - -- > Cheers > Leemailto:[EMAIL PROTECTED] > > $$=qw$808273788400074285838400657879847269820080698276007265677569820727$; > $$=~s$(\d\d)$\$_.=chr(\$1+32)$ge;eval; > > -BEGIN PGP SIGNATURE- > Version: 2.6 > > iQCVAwUAPj+AYqdrfekeF/QBAQErkgQApGgGWv78D4in/2NmcoBTqMPdKKyYUZia > ZN7chLUcduSoyqftj70iU0+PCAheJqX6k+9Q/bErraOoP4g3S5aMW99zYMLfXKtx > XhTHhusNkroSGKpyXI7FlyKOaQqDLN+S8vm5QAlEkZlK6ZfgovgevSnCqfsiuc48 > /EW2drjX1w0= > =Ef7H > -END PGP SIGNATURE- -- 7, College View, Cirencester, Gloucestershire, GL7 1WD, UK 07957 141204 [EMAIL PROTECTED]
Re: cgi and mod_perl-1.26, Apache-1.27, perl-5.8.0, FreeBSD failwith 'The document contained no data'
Lee Goddard wrote: I don't know: you're doing this: print "Content-type: text/plain\n\n"; print "Hello World\n"; Does it (probably not) make any difference if you do a full CRLF, as perldoc perlop: For example, most networking protocols expect and prefer a CR+LF (""\015\012"" or ""\cM\cJ"") for line terminators, and although they often accept just ""\012"", they seldom tolerate just ""\015"". If you get in the habit of using ""\n"" for networking, you may be burned some day. SB> Apache already fixes up "\n\n" to the right thing. What it really does SB> is identifying the Content-type: header, and then adds the terminating SB> by itself, because it really sends other headers, before adding an SB> empty new line. So it shouldn't matter if you say "\r\n\r\n" or just SB> "\n\n", unless there is a bug. So if Apache (mod_perl) adds this to his script, even though it is not a mod_perl script, then shouldn't he be calling it from a that isn't mod_perl enabled...? Sorry, just getting into this Apache module thing The script sends the header, which could be multiline and terminates it with an empty new line. By saying 'PerlSendHeader On' you tell mod_perl to parse the headers (which is actually done by an apache functions) and separate them from the body. Apache then adds other headers (Server token, Date, etc) and sends the response as if it was a mod_perl module. Think of Apache::Registry and friends as mod_cgi on mushrooms. __ Stas BekmanJAm_pH --> Just Another mod_perl Hacker http://stason.org/ mod_perl Guide ---> http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com