You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Mike Wille <mi...@phatness.com> on 2002/03/21 17:37:18 UTC
0 being appended to non mod_perl scripts.
Hello all,
I apologize if this has already been answered elsewhere, I haven't been able
to find it.
I am encountering a wierd problem where perl scripts running under a normal
cgi-bin (ie no mod_perl) have a '0' appended to the output. This does not
happen to scripts run under mod_perl. It also only happens when
PerlSendHeader is set to on. I thought that PerlSendHeader was a mod_perl
only directive, but just to check I added PerlSendHeader off to the cgi-bin
directory. That had no effect.
Has anyone else encountered this and how did you fix it?
Thanks in advanced,
Mike Wille
Re: 0 being appended to non mod_perl scripts.
Posted by Stas Bekman <st...@stason.org>.
Mike Wille wrote:
> There are a few scripts that use system calls (``). There are scripts that
> don't use system calls at all and still have the 0. None of them create any
> subprocesses.
>
> I checked to see if mod_perl was handling the scripts that sent the '0' but
> perl is indeed handling them and not httpd.
As Darren has suggested please try this script:
#!/usr/bin/perl -wT
print "Content-type: text/plain\n\n";
print "Running under ";
print $ENV{MOD_PERL} ? "mod_perl" : "mod_cgi";
and if you get mod_perl, and you don't know to figure out why, start
from scratch, remove all configs you have added to the default
httpd.conf and then start adding one by one and see what you are doing
wrong.
e.g. I don't see where is your ScriptAlias setting. You cannot run
mod_cgi without setting ScriptAlias or using
SetHandler default-handler
for example see:
http://perl.apache.org/guide/config.html#Overriding_Location_Setting_in
and the rest of the chapter
> For testing this problem I have a standard setup:
>
> <Directory "/home/www/cgi-bin">
> AllowOverride None
> Options None
> Order allow,deny
> Allow from all
> Options +ExecCGI
> </Directory>
>
> The mod_perl script directory:
>
> <Directory "/home/www/perl">
> SetHandler perl-script
> PerlHandler Apache::Registry
> Options +ExecCGI
> PerlSendHeader on
> PerlModule Apache::DBI Apache::StatINC
> AllowOverride All
> </Directory>
>
> The server is running Apache 1.3.20. I'm not sure how to find the version
> of mod_perl...
>
> Nothing looks out of wack does it? Anything running in cgi-bin has a '0'
> appended to it and is exceuted by perl. Anything in perl does not have the
> '0' and is executed by httpd.
>
> - Mike
>
> -----Original Message-----
> From: darren chamberlain [mailto:dlc@users.sourceforge.net]
> Sent: Thursday, March 21, 2002 11:49 AM
> To: modperl@perl.apache.org
> Subject: Re: 0 being appended to non mod_perl scripts.
>
>
> Quoting Mike Wille <mi...@phatness.com> [Mar 21, 2002 11:36]:
>
>>I apologize if this has already been answered elsewhere, I
>>haven't been able to find it.
>>
>>I am encountering a wierd problem where perl scripts running
>>under a normal cgi-bin (ie no mod_perl) have a '0' appended to
>>the output. This does not happen to scripts run under
>>mod_perl. It also only happens when PerlSendHeader is set to
>>on. I thought that PerlSendHeader was a mod_perl only
>>directive, but just to check I added PerlSendHeader off to the
>>cgi-bin directory. That had no effect.
>>
>>Has anyone else encountered this and how did you fix it?
>
>
> This looks like an exit code to me. Does the script create
> subprocesses or use system? Also, if PerlSendHeader is making
> the script behave differently, it sounds like mod_perl is
> handling your script (you can check for $ENV{MOD_PERL}).
>
> (darren)
>
> --
> People who are willing to give up freedom for the sake of short
> term security, deserve neither freedom nor security.
> -- Ben Franklin
--
_____________________________________________________________________
Stas Bekman JAm_pH -- Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide http://perl.apache.org/guide
mailto:stas@stason.org http://ticketmaster.com http://apacheweek.com
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/
RE: 0 being appended to non mod_perl scripts.
Posted by Ged Haywood <ge...@www2.jubileegroup.co.uk>.
Hi there,
On Thu, 21 Mar 2002, Mike Wille wrote:
[snip,snip]
> I checked to see if mod_perl was handling the scripts that sent the '0' but
> perl is indeed handling them and not httpd.
I'm not sure I understand what you're saying here.
> The server is running Apache 1.3.20. I'm not sure how to find the version
> of mod_perl...
Does this mean you'vve *never* looked in the error_log???
73,
Ged.
RE: 0 being appended to non mod_perl scripts.
Posted by Mike Wille <mi...@phatness.com>.
There are a few scripts that use system calls (``). There are scripts that
don't use system calls at all and still have the 0. None of them create any
subprocesses.
I checked to see if mod_perl was handling the scripts that sent the '0' but
perl is indeed handling them and not httpd.
For testing this problem I have a standard setup:
<Directory "/home/www/cgi-bin">
AllowOverride None
Options None
Order allow,deny
Allow from all
Options +ExecCGI
</Directory>
The mod_perl script directory:
<Directory "/home/www/perl">
SetHandler perl-script
PerlHandler Apache::Registry
Options +ExecCGI
PerlSendHeader on
PerlModule Apache::DBI Apache::StatINC
AllowOverride All
</Directory>
The server is running Apache 1.3.20. I'm not sure how to find the version
of mod_perl...
Nothing looks out of wack does it? Anything running in cgi-bin has a '0'
appended to it and is exceuted by perl. Anything in perl does not have the
'0' and is executed by httpd.
- Mike
-----Original Message-----
From: darren chamberlain [mailto:dlc@users.sourceforge.net]
Sent: Thursday, March 21, 2002 11:49 AM
To: modperl@perl.apache.org
Subject: Re: 0 being appended to non mod_perl scripts.
Quoting Mike Wille <mi...@phatness.com> [Mar 21, 2002 11:36]:
> I apologize if this has already been answered elsewhere, I
> haven't been able to find it.
>
> I am encountering a wierd problem where perl scripts running
> under a normal cgi-bin (ie no mod_perl) have a '0' appended to
> the output. This does not happen to scripts run under
> mod_perl. It also only happens when PerlSendHeader is set to
> on. I thought that PerlSendHeader was a mod_perl only
> directive, but just to check I added PerlSendHeader off to the
> cgi-bin directory. That had no effect.
>
> Has anyone else encountered this and how did you fix it?
This looks like an exit code to me. Does the script create
subprocesses or use system? Also, if PerlSendHeader is making
the script behave differently, it sounds like mod_perl is
handling your script (you can check for $ENV{MOD_PERL}).
(darren)
--
People who are willing to give up freedom for the sake of short
term security, deserve neither freedom nor security.
-- Ben Franklin
Re: 0 being appended to non mod_perl scripts.
Posted by darren chamberlain <dl...@users.sourceforge.net>.
Quoting Mike Wille <mi...@phatness.com> [Mar 21, 2002 11:36]:
> I apologize if this has already been answered elsewhere, I
> haven't been able to find it.
>
> I am encountering a wierd problem where perl scripts running
> under a normal cgi-bin (ie no mod_perl) have a '0' appended to
> the output. This does not happen to scripts run under
> mod_perl. It also only happens when PerlSendHeader is set to
> on. I thought that PerlSendHeader was a mod_perl only
> directive, but just to check I added PerlSendHeader off to the
> cgi-bin directory. That had no effect.
>
> Has anyone else encountered this and how did you fix it?
This looks like an exit code to me. Does the script create
subprocesses or use system? Also, if PerlSendHeader is making
the script behave differently, it sounds like mod_perl is
handling your script (you can check for $ENV{MOD_PERL}).
(darren)
--
People who are willing to give up freedom for the sake of short
term security, deserve neither freedom nor security.
-- Ben Franklin
Re: 0 being appended to non mod_perl scripts.
Posted by "Jeffrey W. Baker" <jw...@acm.org>.
On Thu, 2002-03-21 at 08:37, Mike Wille wrote:
> Hello all,
>
> I apologize if this has already been answered elsewhere, I haven't been able
> to find it.
>
> I am encountering a wierd problem where perl scripts running under a normal
> cgi-bin (ie no mod_perl) have a '0' appended to the output. This does not
> happen to scripts run under mod_perl. It also only happens when
> PerlSendHeader is set to on. I thought that PerlSendHeader was a mod_perl
> only directive, but just to check I added PerlSendHeader off to the cgi-bin
> directory. That had no effect.
>
> Has anyone else encountered this and how did you fix it?
Are you sure this isn't an artifact of chunked encoding? Perhaps your
browser or Apache are handling the encoding badly.
I suggest you use a tool such as ethereal to examine the data on the
wire.
-jwb
Re: 0 being appended to non mod_perl scripts.
Posted by Dave Hodgkinson <da...@davehodgkinson.com>.
Per Einar Ellefsen <pe...@skynet.be> writes:
> I suspect that you don't get the 0 from static files, or anything
> which sends a Content-Length header. Look more into the raw
> transmitted data, and you might find out something.
Might it be an HTTP/1.1 KeepAlive artefact?
--
David Hodgkinson, Wizard for Hire http://www.davehodgkinson.com
Editor-in-chief, The Highway Star http://www.deep-purple.com
All the Purple Family Tree news http://www.slashrock.com
Interim Technical Director, Web Architecture Consultant for hire
RE: 0 being appended to non mod_perl scripts.
Posted by Per Einar Ellefsen <pe...@skynet.be>.
At 14:48 22.03.2002 -0500, Mike Wille wrote:
>Well, after much testing, I've found the problem does not lie with mod_perl.
>I'm not sure of the source now, I just know how to recreate it. Originally
>it seemed like mod_perl but it was just a coincidence that it the problem
>started after making some configuration changes.
>
>The only thing I need to do to recreate the problem is include a 'use
>Whatever::Module;' in a simple "hello world" Perl script under mod_cgi.
>Mod_perl does not ever append the 0. System and exec calls do not cause the
>0 to be displayed either.
>
>I have no idea what is causing this as the setup is an out of the box Red
>Hat 7.2 installation. But that is off topic... But thanks to everyone who
>answered this post!
In that case it's most probably the point Jeffrey W. Baker noted about
chunked encoding. Your User Agent might not be handling it.
I suspect that you don't get the 0 from static files, or anything which
sends a Content-Length header. Look more into the raw transmitted data, and
you might find out something.
--
Per Einar Ellefsen
per.einar@skynet.be
RE: 0 being appended to non mod_perl scripts.
Posted by Mike Wille <mi...@phatness.com>.
Well, after much testing, I've found the problem does not lie with mod_perl.
I'm not sure of the source now, I just know how to recreate it. Originally
it seemed like mod_perl but it was just a coincidence that it the problem
started after making some configuration changes.
The only thing I need to do to recreate the problem is include a 'use
Whatever::Module;' in a simple "hello world" Perl script under mod_cgi.
Mod_perl does not ever append the 0. System and exec calls do not cause the
0 to be displayed either.
I have no idea what is causing this as the setup is an out of the box Red
Hat 7.2 installation. But that is off topic... But thanks to everyone who
answered this post!
- Mike
-----Original Message-----
From: Stas Bekman [mailto:stas@stason.org]
Sent: Thursday, March 21, 2002 8:56 PM
To: Randal L. Schwartz
Cc: Mike Wille; modperl@perl.apache.org
Subject: Re: 0 being appended to non mod_perl scripts.
Randal L. Schwartz wrote:
>>>>>>"Mike" == Mike Wille <mi...@phatness.com> writes:
>>>>>
>
> Mike> I am encountering a wierd problem where perl scripts running under a
normal
> Mike> cgi-bin (ie no mod_perl) have a '0' appended to the output.
>
> I've seen this happen when people mistakenly write:
>
> print system "foo";
>
> instead of
>
> print `foo`;
>
> but of course they should have written:
>
> system "foo";
>
> instead.
>
> As to why it's not happening in an Apache::Registry script, I cannot
> say.
>
Because , the output of system(), exec(), and open(PIPE,"|program")
calls will not be sent to the browser unless your Perl was configured
with sfio.
http://perl.apache.org/guide/porting.html#Output_from_system_calls
--
_____________________________________________________________________
Stas Bekman JAm_pH -- Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide http://perl.apache.org/guide
mailto:stas@stason.org http://ticketmaster.com http://apacheweek.com
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/
Re: 0 being appended to non mod_perl scripts.
Posted by Stas Bekman <st...@stason.org>.
Randal L. Schwartz wrote:
>>>>>>"Mike" == Mike Wille <mi...@phatness.com> writes:
>>>>>
>
> Mike> I am encountering a wierd problem where perl scripts running under a normal
> Mike> cgi-bin (ie no mod_perl) have a '0' appended to the output.
>
> I've seen this happen when people mistakenly write:
>
> print system "foo";
>
> instead of
>
> print `foo`;
>
> but of course they should have written:
>
> system "foo";
>
> instead.
>
> As to why it's not happening in an Apache::Registry script, I cannot
> say.
>
Because , the output of system(), exec(), and open(PIPE,"|program")
calls will not be sent to the browser unless your Perl was configured
with sfio.
http://perl.apache.org/guide/porting.html#Output_from_system_calls
--
_____________________________________________________________________
Stas Bekman JAm_pH -- Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide http://perl.apache.org/guide
mailto:stas@stason.org http://ticketmaster.com http://apacheweek.com
http://singlesheaven.com http://perl.apache.org http://perlmonth.com/
Re: 0 being appended to non mod_perl scripts.
Posted by "Randal L. Schwartz" <me...@stonehenge.com>.
>>>>> "Mike" == Mike Wille <mi...@phatness.com> writes:
Mike> I am encountering a wierd problem where perl scripts running under a normal
Mike> cgi-bin (ie no mod_perl) have a '0' appended to the output.
I've seen this happen when people mistakenly write:
print system "foo";
instead of
print `foo`;
but of course they should have written:
system "foo";
instead.
As to why it's not happening in an Apache::Registry script, I cannot
say.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<me...@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!