perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Robinson <>
Subject mod_perl2 SubProcess no output from spawn_proc_prog in handler
Date Thu, 22 Jul 2010 16:34:51 GMT
Hi all,
I am trying to figure out how to use spawn_proc_prog to execute an external process and return
the output of that process to the calling browser.
I am currently modifying the spawn_proc_prog example from the mod_perl 2 API docs. 

My perl script is this:
"package ModPerl::Rules2;
use Apache2::SubProcess ();
use Config;
use constant PERLIO_IS_ENABLED => $Config{useperlio};

sub read_data {
	my ($fh) = @_;
	my $data;
	if (PERLIO_IS_ENABLED || IO::Select->new($fh)->can_read(10)) {
		$data = <$fh>;
	return defined $data ? $data : '';
sub handler{
  	my $r = shift;
	my $cmd = "ls";
	my $out_fh = $r->spawn_proc_prog($cmd);
        my $output = read_data($out_fh);
        print "output from spawn_proc_prog goes between this line:\n";
        print $output . "\n";
	print "and this line\n";
        return Apache2::OK;
1; # satisfy require()"

When I start Apache, everything starts fine:
"[Thu Jul 22 11:11:47 2010] [notice] Apache/2.2.14 (Unix) mod_ssl/2.2.14 OpenSSL/0.9.8l DAV/2
mod_perl/2.0.4 Perl/v5.10.0 configured -- resuming normal operations"

When I call the script from my browser, I receive this:
"output from spawn_proc_prog goes between this line:

and this line"

So I know the handler is being called by Apache. And there is nothing new in the Apache error
It is as if spawn_proc_prog ignores me.

I am working on a Mac workstation 10.6.4 with the default installation of Apache and mod_perl

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message