Steven, you need to use those mod-perl libraries to handle the web request
and to generate the response.

https://perl.apache.org/docs/2.0/user/intro/start_fast.html

Scroll down to the bottom, you can see how to output the content.

Cheers,
Joseph


On Mon, May 13, 2024 at 9:35 PM Steven Haigh via modperl <
modperl@perl.apache.org> wrote:

> That being said, is there a way to output to the web page in this scenario?
>
> On 14/5/24 12:15, Joseph He wrote:
> > CGI script runs on its own process. mod-perl basically wraps CGI script
> > into apache process, that is why its output is automatically going to
> > Apache log.
> >
> > On Mon, May 13, 2024 at 1:53 AM Steven Haigh via modperl
> > <modperl@perl.apache.org <mailto:modperl@perl.apache.org>> wrote:
> >
> >     Hi all,
> >
> >     I'm playing around with mod_perl on apache on docker - and now I've
> >     finally got all the module issues sorted, I'm trying to figure out
> why
> >     when using mod_perl, the output of scripts ends up in the apache
> logs.
> >
> >     The following configuration works, and the output of shelled scripts
> >     works as expected:
> >
> >     <Location />
> >           DirectoryIndex index.pl <http://index.pl> index.html
> >           AddHandler cgi-script .pl
> >           Options +Indexes +FollowSymLinks +ExecCGI
> >           Require all granted
> >     </Location>
> >
> >     If I change this to use mod_perl, all output from scripts run in web
> >     pages ends up in the apache log:
> >
> >     <Location />
> >           DirectoryIndex index.pl <http://index.pl> index.html
> >           AddHandler perl-script .pl
> >           Options +Indexes +FollowSymLinks +ExecCGI
> >           Require all granted
> >     </Location>
> >
> >     The perl code I'm using in the web page is as follows:
> >     my $cmd = "/bin/stdbuf";
> >     my @args = qw@ -o1 -e1 /usr/bin/speedtest-cli@;
> >
> >     print '<pre class="alert">';
> >     my $pid = open3(0, \*READER, 0, $cmd, @args);
> >     while ( my $output = <READER> ) {
> >           print $output;
> >     }
> >     print "Speed test complete.</pre>";
> >     waitpid $pid,0;
> >
> >     Does anyone have any clues as to why STDOUT would end up in the
> apache
> >     log and not in the web page being served when using perl-script as
> the
> >     handler?
> >
> >     --
> >     Steven Haigh
> >
> >     📧 net...@crc.id.au <mailto:net...@crc.id.au>
> >     💻 https://crc.id.au <https://crc.id.au>
> >
> >
>
> --
> Steven Haigh
>
> 📧 net...@crc.id.au
> 💻 https://crc.id.au
>
>

Reply via email to