apache and perl cgi oddity

apache and perl cgi oddity

Post by Rex Diete » Fri, 20 Nov 1998 04:00:00

(I've posted here on the idea that apache is doing something odd.  I've posted this
similar question to the appropriate perl and cgi groups too)

I'm seeing strange results when using perl's CGI.pm and IPC::Open3 together.
Any clues?  Am I, perl, CGI.pm, apache, or none or some of the above at fault here?

Here's a simple cgi to illustrate:

#!/usr/local/bin/perl -w
# example.cgi: A perl CGI to demonstrate a problem with open3
# Tested with apache 1.2.6 and 1.3.3 and perl 5.00404 and perl5.00502
# with CGI.pm version 2.43

use CGI;
use IO::Handle;
use IO::File;
use IPC::Open3;
use strict;

# With this line, it at leaset works under apache-1.2.6, but
# results in absolutely no output on apache-1.3.3
# autoflush STDOUT 1;

my $ex = new CGI;  

print   $ex->header(),
        $ex->h1("Example cgi"),
        "An example of a badly behaving cgi script", $ex->hr;

my $reader = new IO::Handle;
my $writer = new IO::Handle;

# This can be ANY external program, I use cat as an example
my $PID = open3($writer,$reader,'', "/bin/cat");

print $writer "Hello1... $PID...\nblah... blah...\n";
undef $writer; # flush/close output TO cat
print <$reader>; # read output FROM cat
print   $ex->end_html;

Here are my findings:
  This script works on the command line fine.
  This script gives quasi double-printed output when executed under apache 1.2.6.  See an
example of what I mean at http://www.math.unl.edu/~rdieter/Projects/example
  This script executes fine when STDOUT is autoflushed under apache 1.2.6
  This script executes, but prints no output from the open3'd process under apache 1.3.3.
  This script produces no output (ie, browser says document has no data), when STDOUT is
autoflushed under apache 1.3.3.

A few more details
Platform: NEXTSTEP 3.3 and Openstep for Mach 4.2
Perl:   versions 5.004_04 and 5.005_02
CGI.pm: version 2.43
Apache: versions 1.2.6 and 1.3.3


Computer System Manager         http://www.math.unl.edu/~rdieter/
Mathematics and Statistics              
University of Nebraska-Lincoln


1. Apache 1.3.14 / Netware Perl/CGI PROBLEM, Please help!

Hi All!

I installed the Apache 1.3.14 binary distribution on my Netware 5.1 Server.
Apache works fine, but I didn't figure out, how CGI support is provided
under Netware. I have a .cgi file, that has "#!perl" as the first line, but
Apache ignores that, and just presents the source as plain/text. Also the
test-cgi files don't work. (Also plain/text, not an internal server

Does anybody has an idea?

Thank you for your help.

with best regards

H. Mayer

2. Apache: problem with htpasswd command

3. Help with apache, perl, and cgi

4. Ethernet RTL8019, not detected at boottime

5. Apache 0.6.5 problems with perl cgi scripts

6. Questions: Large SCSI Partitions, native SCSI partitioning

7. sigsegv by process started via bourne shell by perl cgi script on apache

8. ksh question for solaris

9. coherence perl-cgi-script / apache / ressources

10. RedBaron and Perl CGI via Apache

11. Redirect cgi (perl) scripts using Apache 0.8.14

12. Apache CGI won't run Perl!

13. apache 1.3.3 on WinNT w/PERL CGI