Re: 0 being appended to non mod_perl scripts.

2002-03-22 Thread Jeffrey W. Baker

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.

2002-03-22 Thread Mike Wille

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:[EMAIL PROTECTED]]
Sent: Thursday, March 21, 2002 8:56 PM
To: Randal L. Schwartz
Cc: Mike Wille; [EMAIL PROTECTED]
Subject: Re: 0 being appended to non mod_perl scripts.


Randal L. Schwartz wrote:
Mike == Mike Wille [EMAIL PROTECTED] 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:[EMAIL PROTECTED]  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.

2002-03-22 Thread Per Einar Ellefsen

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
[EMAIL PROTECTED]




Re: 0 being appended to non mod_perl scripts.

2002-03-22 Thread Dave Hodgkinson

Per Einar Ellefsen [EMAIL PROTECTED] 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 Hirehttp://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.

2002-03-21 Thread Stas Bekman

[reminder: keep replies CC'ed to the list! Thanks]

Mike Wille wrote:
 Thanks for the suggestion, but I mentioned earlier that mod_perl is not
 running these scripts appended with a 0.  Everything in cgi-bin which
 includes everything with a 0 appended is being run under mod_cgi.

As I suggested remove all the configurations you have added, and just 
add a simply ScriptAlias and test. still having a problem? than it has 
nothing to do with mod_perl.
Most likely you include some module that prints 0 in the END/DESTROY 
block or something like this.

You didn't answer whether you have the same problem with the script I've 
suggested for you to run. If 0 doesn't appear with this 3 liner, see the 
item above, if the item above doesn't help see the 2nd item above.

e.g. I don't see where is your ScriptAlias setting. You cannot run
mod_cgi without setting ScriptAlias or using
 
 
 I'm sorry, I forgot to throw in the ScriptAlias with the config block I
 emailed earlier.  I do indeed have a ScriptAlias set to:
 
 ScriptAlias /cgi-bin/ /home/www/cgi-bin/

cool


_
Stas Bekman JAm_pH  --   Just Another mod_perl Hacker
http://stason.org/  mod_perl Guide   http://perl.apache.org/guide
mailto:[EMAIL PROTECTED]  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.

2002-03-21 Thread Mike Wille

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:[EMAIL PROTECTED]]
Sent: Thursday, March 21, 2002 11:49 AM
To: [EMAIL PROTECTED]
Subject: Re: 0 being appended to non mod_perl scripts.


Quoting Mike Wille [EMAIL PROTECTED] [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.

2002-03-21 Thread Ged Haywood

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.

2002-03-21 Thread Stas Bekman

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:[EMAIL PROTECTED]]
 Sent: Thursday, March 21, 2002 11:49 AM
 To: [EMAIL PROTECTED]
 Subject: Re: 0 being appended to non mod_perl scripts.
 
 
 Quoting Mike Wille [EMAIL PROTECTED] [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:[EMAIL PROTECTED]  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.

2002-03-21 Thread Randal L. Schwartz

 Mike == Mike Wille [EMAIL PROTECTED] 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
[EMAIL PROTECTED] 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!