John Siracusa wrote: > (I'm not sure if this is a mod_perl thing of a Mac OS X bug, so I'm posting > it to both lists. Redirect follow-ups as appropriate.) > > open2() doesn't seem to work for me when running under mod_perl in Mac OS X.
It's not a bug in MacOSX, it simply doesn't work with mod_perl. the piped program ('upcase' in your example) never sees any input. There are at least two working alternatives: 1) use IPC::Run: #!/usr/bin/perl use strict; use CGI qw(:standard); use IPC::Run qw(start finish) ; local $ENV{PATH}; print header(); my @cmd = qw(/tmp/upcase) ; my $h = start \@cmd, '<pipe', \*IN, '>pipe', \*OUT, '2>pipe', \*ERR or die "@cmd returned $?" ; print IN "Perl::Run and Barrie rule!"; close IN; print <OUT>, <ERR>; finish $h ; the upcase program without any change: #!/usr/bin/perl $buf .= $_ while(<STDIN>); print uc $buf; 2) use Apache::SubProcess: use Apache::SubProcess (); my $r = shift; $r->send_http_header('text/plain'); use vars qw($input); $input = "Apache::SubProcess rules too!"; my($out, $in, $err) = $r->spawn_child(\&upcase); print $out $input; $r->send_fd($in); sub upcase { my $r = shift; $r->subprocess_env(CONTENT_LENGTH => length $input); $r->filename("/tmp/upcase"); $r->call_exec; } notice that the upcase script will be different from yours in this case, it looks like: #!/usr/bin/perl read STDIN, $buf, $ENV{CONTENT_LENGTH}; print uc $buf; As this module lacks any docs, you can find them here: http://perl.apache.org/release/docs/1.0/guide/modules.html#Apache__SubProcess __________________________________________________________________ Stas Bekman JAm_pH ------> Just Another mod_perl Hacker http://stason.org/ mod_perl Guide ---> http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com